python - Matplotlib "Zoom to rectangle"在细矩形上不能很好地缩放

标签 python numpy matplotlib

当您绘制这个 1000x1000 正方形时:

import matplotlib.pyplot as plt, numpy as np
A = np.random.random((1000,1000))
plt.imshow(A)
plt.show()

enter image description here

然后点击缩放到矩形并选择一个细矩形,输出是“不是非常缩放”:

enter image description here

这可能是因为它试图保持纵横比;如何禁用此功能,并使用 maplotlib GUI 窗口中的所有可用空间进行缩放?

最佳答案

正如@DavidG 所指出的,

plt.imshow(A, aspect="auto")

解决了:

enter image description here

关于python - Matplotlib "Zoom to rectangle"在细矩形上不能很好地缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52646649/

相关文章:

python - 如何使用networkx nx.draw()使x轴和y轴出现?

python - 有没有办法在 Python 中使用 subplot2grid 制作本地标题

python - 有没有办法在 NumPy 中使数组条目成为复杂变量?

python - 在 amazon lambda 中使用 moviepy、scipy 和 numpy

python - 使用plot_acf时不显示置信区间

python - matplotlib 补丁可以与函数一起使用吗?

python - 为什么 resample 在 groupby 中比 pd.Grouper 慢得多?

python - 如何用Python编写过滤函数

python-2.7 - conda 更新 scikit-learn(还有 scipy 和 numpy)

algorithm - 在 numpy 中加速矢量化眼动追踪算法