我想在matplotlib图形中只显示绘图图形(或imshow)。我可以通过pylab.axis('off')移除轴线,但仍然有一些灰色边框在图像中。
举个例子,我想删除所有内容,只保留imshow域(并保持缩放可用)。
非常感谢。
举个例子,我想删除所有内容,只保留imshow域(并保持缩放可用)。
非常感谢。
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
尝试使用margins()函数(也是一个轴方法): http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.margins
fig
是您创建的图形,那么fig.patch.set_alpha(0.0)
有帮助吗? - halexfig.set_facecolor('white')
(或者其他你喜欢的颜色)来设置它。 - Joe Kington