I am trying to reproduce the following visualization using altair:
The tricky part is the bars pointing downwards from 100. In the old days I would use matplotlib and subtract 100 from the data but keep the old label ticks. Altair is, fortunately, very true to the data, so this trick doesn't seem to work.
Is there a way to offset the "origin" of the bars? Or is there any other trick that could give the desired result?
Here is a minimal sample code that is relevant:
import altair as alt
import pandas as pd
data = pd.DataFrame({
'num': [0, 1],
'value': [80, 120],
})
alt.Chart(data).mark_bar().encode(x='num', y='value')
You can do this by using a
y2
encoding to specify the baseline. Adapting your example: