python 散点图 置信区间_python - 如何填充matplotlib直方图的中心95%置信区间? - 堆栈内存溢出...

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 15:46   144   0

我可以使matplotlib直方图没问题。 但是,我想知道是否可以使用诸如fillbetween类的fillbetween来更改数据中心95%CI的填充颜色。

我只能得到fillbetween如果我用一招用numpy的直方图和bincenters时工作。 即:

bins = np.linspace(-a.max(),a.max(),400)

hist = np.histogram(a,bins = bins)[0]

bincenters = 0.5*(bins[1:] + bins[:-1])

b = plt.plot(bincenters,hist, linestyle = 'None')

plt.fill_between(bincenters,hist, color = '#7f7f7f')

plt.fill_between(bincenters, hist, interpolate=False,

where=((bincenters>=lower_p) & (bincenters<=upper_p)), hatch = '...', facecolor = '#7f7f7f')```

Here's my existing code that I'd rather use to create the matplotlib histogram (which I think looks better) with some extras plotting on top:

#Create Histogram

axes[1] = boota.plot.hist(ax = axes[1],bins = 50, legend = None, histtype = 'bar', color = '#7f7f7f')

axes[1].set_xlabel('Spatial Decay Rate (α)', size = 16, fontweight = 'bold')

axes[1].set_ylabel('Frequency', labelpad = 11, size = 16, fontweight = 'bold')

#Ticklabels

axes[0].tick_params(labelsize = 14)

axes[1].tick_params(labelsize = 14)

#draw vertical line at remote powerlaw (rem_a)

rem_a = 0.649

axes[1].axvline(x=rem_a, color='k', linestyle='dashed', linewidth=1.5, label='remote decay \nrate $α_r$ = 0.649')

legend = axes[1].legend(ncol = 1, loc = 'upper left', fontsize='large')

legend.draw_frame(False)

at2 = AnchoredText("B",prop=dict(size=20), loc='upper right',frameon=False)

axes[1].add_artist(at2)

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP