Remove grey background borders in matplotlib figure
我只想在matplotlib图中显示绘图图形(或imshow)。 我可以使用pylab.axis('off')删除轴,但是图中仍然有一些灰色边框
我举一个例子。 我只想删除imshow域(并保持缩放可用)。
非常感谢。
尝试margins()函数(也是一种轴方法):
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.margins
对于您的情况,您可能需要重新调整图形窗口的形状以适合内容的形状。 对于平方的窗口,可以使用:
1 2 | fig = figure(figsize=(6, 6)) # width and height in inches fig.tight_layout(pad=0.5) # distance betweeen the axis and the figure edge |
如果需要,请确保为轴标签保留一些空间。 如果只想更改背景颜色,@ JoeKington的评论就是答案。
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tight_layout