尊敬的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')
axes类似乎不能处理多个直方图?如果我错了,请纠正我。在
我的整体绘图是一个1行3列的绘图空间。我想使用网格规范给绘图一个好的布局。在
到目前为止,我的情节是这样的:
这就是我想要的图的直方图部分在阶梯型直方图叠加(带图例)方面的外观:
我将数据集作为从csv文件生成的三个不同元组类型数组。i、 例如,使用x, y = np.genfromtext(datafile.csv)
如果有人能解释这是怎么做到的,我将非常感激。在
你所做的应该是完美的。有没有可能只有一个分布在-1.5到1的x范围内,你之前已经设置了几行?(例如,尝试删除manual
set_xlim
语句,看看是否出现其他发行版。)作为一个快速、独立的示例,可以证明事情应该有效:
(如果希望图例显示线条而不是方框,则需要使用代理艺术家。如果你愿意,我可以加一个例子。不过,这超出了这个问题的范围。)
相关问题 更多 >
编程相关推荐