I am trying to plot two donut charts side by side using matplotlib in python.
First of all I am creating the donut chart using the following logic:
- Create a simple pie chart;
- Pick a position for the chart using the
add_axesfunction; - Add a patch (white circle in it so it can look like a donut chart);
Display the side by side charts on the screen.
fig= plt.figure() circle1 = plt.Circle((0,0), radius= .7 ,color='white') ax1= fig.add_axes([0,0,1,1],aspect=1) ax1.pie(x= values, labels= KA, startangle=30,radius=1.2) ax1.add_patch(circle1) circle2 = plt.Circle((0,0), radius= .7 ,color='white') ax2 = fig.add_axes([1,0,1,1],aspect=1) ax2.pie(x=values2, explode=explode, labels=KA2,startangle=30,radius=1.2) ax2.add_patch(circle2) plt.show()
When it runs the function plt.show() it only displays the first donut chart, with a very strong zoom in it...
What has been driving me crazy is the fact that if I run the following function:
plt.savefig('testplot.png',bbox_inches='tight')
it saves a png file just like I want...
How can I do that on the plt.show()