题
如何使用 Matplotlib 缩放y轴?我不想改变y限制,我只是想扩展物理空间。
^ ^
| |
| |
+----> |
Before +---->
After
解决方案
在实例化图形时,只需使用更大的高度值:
from pylab import *
x = linspace(0, 10*pi, 2**10)
y = sin(x)
figure(figsize=(5, 10))
plot(x, y)
show()
其中 figsize =(width,height)
,默认为(8,6)
。值以英寸为单位( dpi
关键字arg可用于定义 DPI 对于图,并且 matplotlibrc
文件中有一个默认值)
对于已创建的图形,我相信有一个 set_size_inches(width,height)
方法。
其他提示
使用subplots_adjust函数来控制空格的删除:
fig.subplots_adust(bottom = 0.05,top = 0.95)
工具栏上有一个图标,可以通过窗口小部件交互式地执行此操作
不隶属于 StackOverflow