Matplotlib removes the white border (padding) when .set_aspect = 'equal'

in matplotlib, the set_aspect ('equal') parameters override the fill settings (white border). As a result, the output is a square square filled with spaces. How to override this behavior, so the set_aspect parameter applies only to the contour plot, and not throughout the output.

import matplotlib.pyplot as plt plt.axes().set_aspect('equal') 

or

 CS = plt.contourf(xi,yi,zi,30,cmap=plt.cm.jet,antialiased=True,alpha=0.4,norm=c_scale,aspect='equal') 
+4
source share
1 answer

The axes.set_aspect function sets the aspect of the plotting area. If you want the result (image or drawing) to have different heights, widths, take a look at the arguments matplotlib.figure.Figure or matplotlib.figure.savefig .

+1
source

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


All Articles