My dataset contains information on the short-term and long-term effects of a decision support model. I would like to plot this in a barplot, with 4 bars:
- model on, short term
- model on, long term
- model off, short term
- model on, long term
here is some sample code:
df = pd.DataFrame(columns=["model", "time", "value"])
df["model"] = ["on"]*2 + ["off"]*2
df["time"] = ["short", "long"] * 2
df["value"] = [1, 10, 2, 4]
sns.barplot(data=df, x="model", hue="time", y="value")
plt.show()
it looks like this:
There are many other related figures and they have established color conventions. Model on/off is encoded in the hue of the color. Longterm vs shortterm is encoded in the saturation of the color. So let's assume that I have given variables with color values. How can I assign each individual bar in the barplot an individual color?
The docs for seaborn.barplot only show color
, which specifies one color for all elements and palette
which only gives different hue values different colors.