Hi there,
i have the dataframe below. Iām basically happy how its structured and displayed, but is there a way that the columns āA_xā and āA_yā have the same color (for instance red) and can only be distinguished by the pattern? The columns āB_xā and āB_yā should both be blue but āB_yā with a pattern and so on.
Any suggestion?
import pandas as pd
import plotly.express as px
COLORS = ["red", "blue", "green", "cyan"]
df = pd.DataFrame(
{
"DEV" : ["L", "S", "G", "L", "S", "G", "L", "S", "G", "L", "S", "G"],
"Par" : ["A_x", "A_x", "A_x", "A_y", "A_y", "A_y", "B_x", "B_x", "B_x", "B_y", "B_y", "B_y" ],
"Val" : [0.14, 1.06, 1.61, 0.56, 0.84, 1.85, 1.13, 0.47, 1.33, 2.53, 0.97, 1.35],
"Dir" : ["x", "x", "x", "y", "y", "y", "x", "x", "x", "y", "y", "y"]
}
)
bar_chart = px.bar(
df,
x="DEV",
y="Val",
color="Par",
barmode='group',
color_discrete_sequence=COLORS,
text_auto=True,
pattern_shape="Dir"
)
bar_chart.show()