我可以使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)