matplotlib将子图组合成一个没有轴,没有间隙的单个图
我的图像看起来像:
它是使用matplotlib生成的:
for slice_idx in range(mandrill_t.highpasses[1].shape[2]):
print(slice_idx)
subplot(2, 3, slice_idx+1)
imshow(np.abs(mandrill_t.highpasses[1][:,:,slice_idx]), cmap='Spectral', clim=(0, 1))
但是,对于我的用例,我希望在没有间隙或轴的单个图像中所有这6张图像 - 我确实可以没有示例输出图像要显示,但是从本质上讲,我希望它们水平堆叠(其中3个)和垂直(其中2个),以便6个图像是一个图像。
我试图四处寻找类似的问题来吸引灵感,但到目前为止还没有运气:(
任何指针都会很棒。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须指定网格参数:
matplotlib.pyplot.subplots
:然后,您可以循环循环越过创建的轴,对于每个轴,您都必须显示图像并设置图像轴至
'tight'
firtsly和'off'
其次:您的代码会很忽略不同,因为您正在为每个
ax AX
绘制不同的图像。完成代码
You have to specify the grid parameters:
with
matplotlib.pyplot.subplots
:Then you can loop over created axes and, for each one of them, you have to show the image and set axis to
'tight'
firtsly and'off'
secondly:Your code would be slighlty different, since you are plotting different images for each
ax
.Complete Code
这就是是(请参阅代码>文档):
只需在开始时添加以下行:
您可能还必须将一些绘图元素设置为隐形,但很难确切地弄清楚没有MCVE的哪个。
That's what
GridSpec
is for (seeplt.subplots
docs):Just add the following line at the start:
You might also have to set some plot elements to invisible but it's hard to figure out exactly which without an MCVE.