Home > Software engineering >  Matplotlib: filled areas, alpha and hide gridlines
Matplotlib: filled areas, alpha and hide gridlines

Time:07-02

Gridlines can be set behind the plot of a filled area by using either ax.set_axisbelow(True) or plt.rc('axes', axisbelow=True) (enter image description here

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)

overlapping histograms with no gridlines through them

  • Related