删除matplotlib figu中的灰色背景边框

2024-06-16 17:44:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我只想在matplotlib figure中显示绘图图形(或imshow)。我可以用幽门轴('off')但是我在图enter image description here

我举个例子。我想删除所有并只保留imshow域(并保持缩放可用)。在

非常感谢。在


Tags: 图形绘图matplotlib例子figureimshowoff幽门
2条回答

尝试margins()函数(也是一个axis方法): http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.margins

在您的例子中,您可能需要重塑图形窗口以适应内容的形状。对于方形窗口,可以使用:

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

相关问题 更多 >