Home > Net >  Making a transparent area within a stacked area chart in Matplotlib
Making a transparent area within a stacked area chart in Matplotlib

Time:08-13

I am trying to build this type of chart: a mix between a line chart and a stacked area chart using Matplotlib and seaborn. I just want the white area below to be fully transparent. I tried changing the alpha parameter but it does not make the area transparent, just white at best. I am using the below code:

plt.plot(df.index,"5y Avg",data=df,
         color=avg_color,
         linestyle="dotted",
         label= '5y Avg')

plt.stackplot(df.index,df["5Y Max"],color="#B1B3B6",labels= ['5y Range'])
    
plt.stackplot(df_test.index,df["5Y Min"],color="white",alpha=1)

stacked area chart

CodePudding user response:

You can get the effect you want simply by changing the approach to the problem: in place of making transparent the area of the bottom stackplot, you can color only the portion of the graph you want with enter image description here

  • Related