Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. %matplotlib inline
  2. import matplotlib.pyplot as plt
  3. import matplotlib.style as style
  4. import seaborn as sns
  5.  
  6. plt.rcParams["figure.figsize"] = (12,12)
  7. # Improve style of the plots
  8. style.use('seaborn-deep')
  9. style.use('ggplot')
  10.  
  11. top_no = 10
  12. pie_data = df
  13. .groupby('country')['name']\
  14. .nunique()\
  15. .nlargest(top_no)\
  16. .to_frame()
  17.  
  18. fig1, ax1 = plt.subplots()
  19. ax1.pie(x=pie_data['name'],
  20. labels=pie_data.index,
  21. autopct='%1.1f%%',
  22. startangle=180)
  23. centre_circle = plt.Circle((0,0),0.70,fc='white')
  24. fig = plt.gcf()
  25. fig.gca().add_artist(centre_circle)
  26. fig.gca().set_title(f"Top {top_no} names")
  27. ax1.axis('equal')
  28. plt.tight_layout()
  29. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement