matplotlib sharey imshow不对齐

发布于 2025-01-19 08:19:35 字数 593 浏览 4 评论 0原文

我正在尝试绘制2个不同尺寸的图像,并与对齐的Y轴并排并排,但它不起作用。请参阅下面的示例

import numpy as np
import matplotlib.pyplot as plt

data0 = np.random.randint(0,128, size=(128,256))
data1 = np.random.randint(0,128, size=(128,128))

fig, (ax0,ax1) = plt.subplots(1,2, sharey=True)
ax0.imshow(data0)
ax1.imshow(data1)

plt.show()

,它显示了类似的内容:

“

,我想要的是使左侧的平方图像(ysize = 128)变小,以使y轴完全与图像完美地对齐左(也ysize = 128)。

I am trying to plot 2 different size images, side-by-side with aligned y-axis, but it is not working. See example below

import numpy as np
import matplotlib.pyplot as plt

data0 = np.random.randint(0,128, size=(128,256))
data1 = np.random.randint(0,128, size=(128,128))

fig, (ax0,ax1) = plt.subplots(1,2, sharey=True)
ax0.imshow(data0)
ax1.imshow(data1)

plt.show()

And it is showing something like this:

imshow example

And what I want is that the square image on the left (ysize=128) is made smaller so that the y-axis are perfectly aligned with the image on the left (also ysize=128).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文