为什么我的colorbar不出现在这个ImageGrid图中?

时间:2013-04-23 15:43:24

标签: matplotlib colorbar

我设法使用hist2dImageGrid制作了一组子图,其代码如下:

from mpl_toolkits.axes_grid1 import ImageGrid

fig = figure(figsize(20, 60))
grid = ImageGrid(fig, 111, nrows_ncols=(1, 3), axes_pad=0.25)
for soa, ax in zip(soalist, grid):
    # grab my data from pandas DataFrame...
    samps = allsubs[allsubs['soa'] == soa]
    x, y = samps['x'], samps['y']

    # calls hist2d and returns the Image returned by hist2d
    img = gazemap(x, y, ax, std=True, mean=True)
    ax.set_title("{0} ms".format(soa * 1000))

# attempt to show a colorbar for that image       
grid.cbar_axes[-1].colorbar(img)

show()  # threw this in for good measure, but doesn't help!

我没有明确错误(这很好,因为我将Image传递给了colorbar),但我的颜色栏没有出现。是什么给了什么?

1 个答案:

答案 0 :(得分:1)

好的,我修好了!

我所要做的就是将cbar_modecbar_location kwargs传递给ImageGrid