Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %matplotlib inline
- import matplotlib.pyplot as plt
- import matplotlib.style as style
- import seaborn as sns
- plt.rcParams["figure.figsize"] = (12,12)
- # Improve style of the plots
- style.use('seaborn-deep')
- style.use('ggplot')
- top_no = 10
- pie_data = df
- .groupby('country')['name']\
- .nunique()\
- .nlargest(top_no)\
- .to_frame()
- fig1, ax1 = plt.subplots()
- ax1.pie(x=pie_data['name'],
- labels=pie_data.index,
- autopct='%1.1f%%',
- startangle=180)
- centre_circle = plt.Circle((0,0),0.70,fc='white')
- fig = plt.gcf()
- fig.gca().add_artist(centre_circle)
- fig.gca().set_title(f"Top {top_no} names")
- ax1.axis('equal')
- plt.tight_layout()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement