小编Ror*_*ory的帖子

将共享轴图添加到 matplotlib 中的 AxesGrid 图

我想在 matplotlib 中创建一个 2x3 的 2d 直方图,在每个子图的顶部有一个共享的颜色条和一个 1d 直方图。除了最后一部分,AxesGrid 为我提供了一切。我尝试按照上述页面上的“scatter_hist.py”示例使用make_axes_locatable. 代码如下所示:

plots = []
hists = []
for i, s in enumerate(sim):
    x = np.log10(s.g['temp']) #just accessing my data
    y = s.g['vr']
    histy = s.g['mdot']
    rmin, rmax = min(s.g['r']), max(s.g['r'])
    plots.append(grid[i].hexbin(x, y, C = s.g['mass'],
                 reduce_C_function=np.sum, gridsize=(50, 50),
                 extent=(xmin, xmax, ymin, ymax),
                 bins='log', vmin=cbmin, vmax=cbmax))
    grid[i].text(0.95 * xmax, 0.95 * ymax,
                 '%2d-%2d kpc' % (round(rmin), round(rmax)),
                 verticalalignment='top',
                 horizontalalignment='right')

    divider = make_axes_locatable(grid[i])
    hists.append(divider.append_axes("top", 1.2, pad=0.1, …
Run Code Online (Sandbox Code Playgroud)

python plot matplotlib

5
推荐指数
1
解决办法
1128
查看次数

标签 统计

matplotlib ×1

plot ×1

python ×1