【问题标题】:Why isn't my colorbar appearing in this ImageGrid plot?为什么我的颜色条没有出现在这个 ImageGrid 图中?
【发布时间】:2013-04-23 15:43:24
【问题描述】:

我已经设法使用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),但我的颜色条没有出现。什么给了?

【问题讨论】:

    标签: matplotlib colorbar


    【解决方案1】:

    好的,我修好了!

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

    【讨论】:

      猜你喜欢
      • 2020-05-25
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      • 2013-02-06
      • 1970-01-01
      • 2016-10-21
      • 2021-12-25
      • 2014-10-27
      相关资源
      最近更新 更多