How to draw a round pie in size without a square in matplotlib / python

I would like to draw a round cake in a rectangular shape. At the moment I am using something like:

fig = plt.figure( figsize = figsize, dpi=inch) # plot actually ax = fig.add_subplot( 1, 1, 1 ) ax.pie( value_list, labels = labels_list, **kwargs ) plt.savefig( plt_pathname ) plt.close() 

If the figure is not square (for example, [4, 4]), then the resulting figure will be stretched, elipsoid. Can i overcome this problem. thanks in advance

+6
source share
1 answer

Just use ax.set_aspect(1) or ax.axis('equal') . (Or plt.axis('equal') )

ax.axis('equal') also set the x and y limits to the same, and also set the aspect of the graph to 1. In your case, this is probably the best option.

+10
source

Source: https://habr.com/ru/post/903305/


All Articles