So I have the following code:
workload_df = pd.DataFrame({
'index': pd.to_datetime(['01.02.2010', '01.03.2010', '01.04.2010']),
'measure': [100, 90, 120],
'measure_max': [80, 100, 150],
})
measure_max_plot = alt.Chart(workload_df).mark_bar(color = 'lightgreen', text = 'measure_max').encode(
alt.X('index', title = '', axis = alt.Axis(labelAngle = -45, labelOverlap = False)),
alt.Y('measure_max', title = '')
)
measure_plot = alt.Chart(workload_df).mark_bar(text = 'measure').encode(
x = alt.X('index', title = 'X', axis = alt.Axis(labelAngle = -45, labelOverlap = False)),
y = alt.Y('measure', title = 'Y'),
color=alt.condition(
alt.datum.measure > alt.datum.measure_max,
alt.value('red'),
alt.value('steelblue')
)
)
altair_plot = alt.layer(measure_max_plot, measure_plot)
st.altair_chart(altair_plot, use_container_width=True)
I already tried adding a legend, by using this solution: Add legend to line & bars to Altair chart without using size/color
But got a weird error all the time or got a legend without any plotted data.
Can anyone help me with that?
