Reputation: 2014
I have a pretty simple pie chart in pyplot
. The relevant code is this:
labels = 'SLoC', 'Violation'
sizes = [nrOfLines-totviols, totviols]
colors = ['#005fab', 'lightcoral']
explode = (0, 0.1)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('scaled')
plt.savefig("/usr/share/scaweb/static/plot-ratio.png", transparent=True, bbox_inches='tight', pad_inches=0)
In the picture, the pie chart is trimmed, which is wierd as the labels outside of the chart are still fully visible:
I'm using matplotlib
version 1.2.
Upvotes: 2
Views: 994
Reputation: 87356
The problem you are having is that the circle is extending past the edges of the (axes that you can not see, but are there as the library sees the figure) and hence is getting clipped. This:
[__.set_clip_on(False) for __ in plt.gca().get_children()]
should fix it, but you might want to report this as a bug.
Upvotes: 3