Skip to content

Instantly share code, notes, and snippets.

@mkhorasani
Last active Oct 10, 2021
Embed
What would you like to do?
def donut_chart(value):
if value >= 80:
color = [0.4392,0.6784,0.2784]
if (value < 80) and (value >= 60):
color = [0.9569,0.6941,0.5137]
if value < 60:
color = [1.0000,0.4118,0.4118]
my_circle=plt.Circle( (0,0), 0.8, color=[0.4902,0.8000,1.0000])
if value > 0:
values = [value, 100 - value]
plt.pie(values,
wedgeprops = { 'linewidth' : 0, 'edgecolor' : 'white' }, colors=[color,[1,1,1]],labeldistance=1.1)
if value < 0:
values = [-value, 100 + value]
plt.pie(values,
wedgeprops = { 'linewidth' : 0, 'edgecolor' : 'white' }, colors=[color,color_b],labeldistance=1.1, counterclock=False)
p=plt.gcf()
p.gca().add_artist(my_circle)
plt.savefig('fig2.png',orientation='portrait',transparent=True, bbox_inches=None, pad_inches=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment