I try to build a line chart that displays a value for each month of a full year. I also want to fill months that exceed a threshold. I have an issue with the appearance of the last values of both the line and the fill.
import altair as alt
from vega_datasets import data
source = data.stocks()
year_data = source[source.date.dt.year == 2007]
line = alt.Chart(year_data, width=600).mark_line(
interpolate='step-after',
color='red'
).encode(
x='date',
y='price'
).transform_filter(alt.datum.symbol == 'IBM')
fill = alt.Chart(year_data, width=600).mark_area(
interpolate='step-after',
).encode(
x='date',
y='price',
).transform_filter(
(alt.datum.symbol == 'IBM') &
(alt.datum.price > 105)
)
fill + line
- How can I display December with the same width as the other months so it does not get chopped off visually?
- October also exceeds the threshold of 105 but doesn't appear to be filled. What can I do to fill it like the other months?


