Last active
October 10, 2021 15:24
-
-
Save mkhorasani/fa23822de0c815ab5c73428ec19a10a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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