python - 在 Python 中使用 Matplotlib 缩放 y 轴

标签 python matplotlib

如何使用 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/

相关文章:

python - 使用 Spark DataFrames 对多个字符串分类特征进行一次性编码

python - Hindmarsh-Rose 模型的相空间轨迹

python - 通过热图填充多边形

python - 正则表达式:如何匹配字符串末尾的键值对序列

python - 类型错误 : object of type 'NoneType' has no len() in beautifulsoup & selenium Python

python - 简单用例的闭包

python - 删除数组中的每第 n 个元素

python - 绘制 100% 堆积图问题

fonts - Matplotlib 字体系列 : using Arno Pro or other fonts

python - 使用 PyQt 和 matplotlib 在可滚动小部件中显示多个图