如何使用 Matplotlib 缩放 y 轴?我不想改变 y-limit,我只想扩展物理空间。
^ ^
| |
| |
+----> |
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
关键字参数可用于定义图形的 DPI,并且在您的 matplotlibrc
文件中有一个默认值)
对于已经创建的图形,我相信有一个 set_size_inches(width, height)
方法。
关于python - 在 Python 中使用 Matplotlib 缩放 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/401787/