【发布时间】:2014-11-01 18:46:45
【问题描述】:
亲爱的 python/matplotlib 社区,
我在 matplotlib 中遇到问题:我似乎无法使用以下方法在同一绘图空间中绘制多个重叠直方图:
binsize = 0.05
min_x_data_sey, max_x_data_sey = np.min(logOII_OIII_sey), np.max(logOII_OIII_sey)
num_x_bins_sey = np.floor((max_x_data_sey - min_x_data_sey) / binsize)
min_x_data_comp, max_x_data_comp = np.min(logOII_OIII_comp), np.max(logOII_OIII_comp)
num_x_bins_comp = np.floor((max_x_data_comp - min_x_data_comp) / binsize)
min_x_data_sf, max_x_data_sf = np.min(logOII_OIII_sf), np.max(logOII_OIII_sf)
num_x_bins_sf = np.floor((max_x_data_sf - min_x_data_sf) / binsize)
axScatter_farright = fig.add_subplot(gs_right[0,0])
axScatter_farright.tick_params(axis='both', which='major', labelsize=10)
axScatter_farright.tick_params(axis='both', which='minor', labelsize=10)
axScatter_farright.set_ylabel(r'$\mathrm{N}$', fontsize='medium')
axScatter_farright.set_xlim(-1.5, 1.0)
axScatter_farright.set_xlabel(r'$\mathrm{log([OII]/[OIII])}$', fontsize='medium')
axScatter_farright.hist(logOII_OIII_sey, num_x_bins_sey, ec='0.3', fc='none', histtype='step')
axScatter_farright.hist(logOII_OIII_comp, num_x_bins_comp, ec='0.3', fc='none', histtype='step')
axScatter_farright.hist(logOII_OIII_sf, num_x_bins_sf, ec='0.3', fc='none', histtype='step')
好像轴类不能处理多个直方图?如果和/或哪里出了问题,请纠正我。
我的整体情节是 1 行 3 列的绘图空间。我想使用网格规范为地块提供良好的布局。
这是我的情节到目前为止的样子:
这就是我希望图形的直方图部分在步骤类型直方图叠加(带有图例)方面看起来像:
我将数据集作为从 csv 文件生成的三个不同的元组类型数组。即,使用x, y = np.genfromtext(datafile.csv)
如果有人能够解释如何做到这一点,我将非常感激。
【问题讨论】:
标签: python matplotlib plot histogram