Gridlines can be set behind the plot of a filled area by using either ax.set_axisbelow(True)
or plt.rc('axes', axisbelow=True)
(
CodePudding user response:
There is no capacity for conditional alphas in Matplotlib; that would be quite an API!
I would just make a white version of the histograms behind the ones I wanted to be alpha:
kwargs0 = dict(histtype='stepfilled', color='w', density=True, bins=40)
kwargs = dict(histtype='stepfilled', alpha=.3, density=True, bins=40)
fig,ax = plt.subplots()
ax.hist(x1, **kwargs0)
ax.hist(x2, **kwargs0)
ax.hist(x3, **kwargs0)
ax.hist(x1, **kwargs)
ax.hist(x2, **kwargs)
ax.hist(x3, **kwargs)