import pandas as pd
import matplotlib.pyplot as plt
df1 = pd.DataFrame({'sizes':[75, 30, 45, 10]},
index=['Frogs', 'Hogs', 'Dogs', 'Logs'])
tot = df1.sizes.sum()
ax = df1.plot.pie(y='sizes',
autopct=lambda p:f'{p/100:.2%}\n({round(p*tot/100.):.0f})',
title=f'Proportion of each class (N={tot})',
figsize=(5,5),
label='',
legend=False);
# Save locally:
plt.savefig('pd_pie.png')
- Run the code block locally to obtain the image
- Create gist with initial code above (only the code block)
- Drop the image file in a comment to the gist & copy the link
- Edit the gist file by adding the copied (markdown) link before/after the code block & update
- Delete the comment
(I prepended the image link to the code block because I wanted the image visible in my list of gists.)