开发者

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

in matplotlib the set_aspect('e开发者_如何转开发qual') settings overrides the padding(white border) settings. As a result the output is a square boxed filled with whitespace. How do I override this behavior, so that the set_aspect setting only applies to the contourf plot and not the entire 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')


The axes.set_aspect function sets the plotting area aspect. If you want the output (image or figure) have different height, width, take a look at the matplotlib.figure.Figure arguments or matplotlib.figure.savefig.


When you save your file, you should use

plt.savefig("out.png", bbox_inches="tight")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜