I would like to give custom color to each component of the stacked bar plot.
import numpy as np
import matplotlib.pyplot as plt
labels = ['Cars', 'Electric/\nHybrid/\nFuel', 'Diesel/\nOctane/\nPremium']
row1 = [2000,1800,1200]
row2 = [0,110,280]
row3 = [0,90,320]
width = 0.35
fig, ax = plt.subplots()
ax.bar(labels, row1, width, color='seagreen')
ax.bar(labels, row2, width, bottom=row1, color='gray')
ax.bar(labels, row3, width, bottom=np.array(row2)+np.array(row1), color='orange')
ax.set_ylim(0,2200)
plt.show()
I would like to give custom colors to each component of the stacked barplot in column 2 and column 3. Column 2 is showing the breakdown of column 1, and column 3 is showing the breakdown of the green component of column 2.