team-10/venv/Lib/site-packages/altair/examples/line_with_ci.py

23 lines
502 B
Python
Raw Normal View History

2025-08-02 02:00:33 +02:00
"""
Line Chart with Confidence Interval Band
----------------------------------------
How to make a line chart with a bootstrapped 95% confidence interval band.
"""
# category: line charts
import altair as alt
from vega_datasets import data
source = data.cars()
line = alt.Chart(source).mark_line().encode(
x='Year',
y='mean(Miles_per_Gallon)'
)
band = alt.Chart(source).mark_errorband(extent='ci').encode(
x='Year',
y=alt.Y('Miles_per_Gallon', title='Miles/Gallon'),
)
band + line