- #253 Control color on stacked area
- #253 Control color on stacked area
Once you understand how to create a stacked area chart and which baseline option to choose, it’s highly recommended to custom the colors of your chart. Here I propose 2 solutions: the first consists to use a common color palette, the second allows you to pick up your colors one by one.
# library import numpy as np import matplotlib.pyplot as plt import seaborn as sns # Your x and y axis x=range(1,6) y=[ [10,4,6,5,3], [12,2,7,10,1], [8,18,5,7,6] ] # use a known color palette (see..) pal = sns.color_palette("Set1") plt.stackplot(x,y, labels=['A','B','C'], colors=pal, alpha=0.4 ) plt.legend(loc='upper right') plt.show() # create your palette pal = ["#9b59b6", "#e74c3c", "#34495e", "#2ecc71"] plt.stackplot(x,y, labels=['A','B','C'], colors=pal, alpha=0.4 ) plt.legend(loc='upper right')