Mr.*_*ers 5 python datagrid matplotlib colorbar
免责声明:一般而言,我对使用matplotlib和python经验不足。
这是我要制作的图:
使用GridSpec布局效果很好,但是当我尝试在每行的右侧添加一个颜色条时,它会更改相应子图的大小。这似乎是的一个众所周知且不可避免的问题GridSpec。因此,根据以下问题的建议:Matplotlib 2 Subplots,1 Colorbar
我决定使用来重新制作整个图ImageGrid。不幸的是,文档仅列出了选项,cbar_mode=[None|single|each]而我希望每行1个colobar。有没有办法在一个内部做到这一点ImageGrid?还是我必须制作2个网格并处理对齐的噩梦。
底部的第五个图呢?有没有办法以某种方式将其包括在图像网格中?
我看到此工作的唯一方法是将两个ImageGridS 嵌套GridSpec在1x3列中。这似乎过于复杂和困难,因此在我知道正确的方法之前,我不希望构建该脚本。
感谢您的帮助/建议!
好吧,我想通了。它似乎ImageGrid以subplot某种方式在其中使用。所以我能够使用类似的东西生成以下图
TopGrid = ImageGrid( fig, 311,
nrows_ncols=(1,2),
axes_pad=0,
share_all=True,
cbar_location="right",
cbar_mode="single",
cbar_size="3%",
cbar_pad=0.0,
cbar_set_cax=True
)
<Plotting commands for the top row of plots and colorbar>
BotGrid = ImageGrid( fig, 312,
nrows_ncols=(1,2),
axes_pad=0,
share_all=True,
cbar_location="right",
cbar_mode="single",
cbar_size="3%",
cbar_pad=0.0,
)
<Plotting commands for bottom row . . .>
StemPlot = plt.subplot(313)
<plotting commands for bottom stem plot>
Run Code Online (Sandbox Code Playgroud)
编辑:颜色图中的空白是故意的,而不是添加颜色条的一些人工制品