From ca16acaf346815ffcc1b9baf41425ed2beac97b5 Mon Sep 17 00:00:00 2001 From: palewire Date: Sun, 3 Jul 2022 07:34:21 -0700 Subject: [PATCH 1/8] Add line chart with interpolation --- altair/examples/line_chart_with_interpolation.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 altair/examples/line_chart_with_interpolation.py diff --git a/altair/examples/line_chart_with_interpolation.py b/altair/examples/line_chart_with_interpolation.py new file mode 100644 index 000000000..6e4d1bd9c --- /dev/null +++ b/altair/examples/line_chart_with_interpolation.py @@ -0,0 +1,15 @@ +""" +Line Chart with Interpolation +----------------------------- +This chart shows a line chart with the path interpolated. A full list of interpolation methods is available `in the documentation `_. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.wheat() + +alt.Chart(source).mark_line(interpolate="monotone").encode( + x="year:O", + y="wheat:Q" +).properties(width=600) From d7e12b9437d436158149c5dc789d719d0446829b Mon Sep 17 00:00:00 2001 From: palewire Date: Sun, 3 Jul 2022 07:35:46 -0700 Subject: [PATCH 2/8] Switch line chart to points to use wheat data --- altair/examples/line_chart_with_points.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/altair/examples/line_chart_with_points.py b/altair/examples/line_chart_with_points.py index 26bd54310..69e1e3aea 100644 --- a/altair/examples/line_chart_with_points.py +++ b/altair/examples/line_chart_with_points.py @@ -7,18 +7,13 @@ """ # category: line charts import altair as alt -import numpy as np -import pandas as pd +from vega_datasets import data -x = np.arange(100) -source = pd.DataFrame({ - 'x': x, - 'f(x)': np.sin(x / 5) -}) +source = data.wheat() alt.Chart(source).mark_line( point=alt.OverlayMarkDef(color="red") ).encode( - x='x', - y='f(x)' -) + x='year:O', + y='wheat:Q' +).properties(width=600) From fede56116e91a02603606c258cd0dbfb322db1cc Mon Sep 17 00:00:00 2001 From: palewire Date: Sun, 3 Jul 2022 07:36:42 -0700 Subject: [PATCH 3/8] Add stroked points --- .../line_chart_with_stroked_points.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 altair/examples/line_chart_with_stroked_points.py diff --git a/altair/examples/line_chart_with_stroked_points.py b/altair/examples/line_chart_with_stroked_points.py new file mode 100644 index 000000000..bf8ec89bd --- /dev/null +++ b/altair/examples/line_chart_with_stroked_points.py @@ -0,0 +1,21 @@ +""" +Line Chart with Stroked Points +------------------------------ +This chart shows a line chart with stroked points marking each value. +""" +# category: line charts +import altair as alt +from vega_datasets import data + +source = data.wheat() + +base = alt.Chart(source).encode( + x="year:O", + y="wheat:Q" +) + +line = base.mark_line() + +point = base.mark_point(fill="white", stroke="steelblue") + +(line + point).properties(width=600) From d77bc24226e4bfdb0f77c3dc85c37fba4172146d Mon Sep 17 00:00:00 2001 From: palewire Date: Sun, 3 Jul 2022 07:38:07 -0700 Subject: [PATCH 4/8] Tidy multi series line chart --- altair/examples/multi_series_line.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/altair/examples/multi_series_line.py b/altair/examples/multi_series_line.py index ffd68501e..9d593be42 100644 --- a/altair/examples/multi_series_line.py +++ b/altair/examples/multi_series_line.py @@ -1,18 +1,17 @@ """ -Multi Series Line Chart ------------------------ +Multiple Series Line Chart +-------------------------- -This example shows how to make a multi series line chart of the daily closing stock prices for AAPL, AMZN, GOOG, IBM, and MSFT between 2000 and 2010. +This example shows how to make a line chart with multiple series of data. """ # category: line charts import altair as alt from vega_datasets import data -source = data.stocks() +source = data.iowa_electricity() alt.Chart(source).mark_line().encode( - x='date', - y='price', - color='symbol', - strokeDash='symbol', + x="year", + y="net_generation", + color="source" ) From ac6e940f2d233bc0b1e4b8805cf5c92cf55a65bf Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Sun, 3 Jul 2022 07:42:52 -0700 Subject: [PATCH 5/8] Update multi_series_line.py --- altair/examples/multi_series_line.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/altair/examples/multi_series_line.py b/altair/examples/multi_series_line.py index 9d593be42..f5b82fed0 100644 --- a/altair/examples/multi_series_line.py +++ b/altair/examples/multi_series_line.py @@ -8,10 +8,10 @@ import altair as alt from vega_datasets import data -source = data.iowa_electricity() +source = data.stocks() alt.Chart(source).mark_line().encode( - x="year", - y="net_generation", - color="source" + x='date', + y='price', + color='symbol', ) From 3b5b1957eb3eb6848f0cc42e8f5e1ffa721aea1d Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Tue, 5 Jul 2022 14:05:34 -0700 Subject: [PATCH 6/8] Update multi_series_line.py --- altair/examples/multi_series_line.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/altair/examples/multi_series_line.py b/altair/examples/multi_series_line.py index f5b82fed0..024ffb636 100644 --- a/altair/examples/multi_series_line.py +++ b/altair/examples/multi_series_line.py @@ -11,7 +11,7 @@ source = data.stocks() alt.Chart(source).mark_line().encode( - x='date', - y='price', - color='symbol', + x='date:T', + y='price:Q', + color='symbol:N', ) From 2c06ff60e2931e2b12d67632182b87a0a8202dd3 Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Tue, 5 Jul 2022 14:14:54 -0700 Subject: [PATCH 7/8] Update line_chart_with_interpolation.py --- altair/examples/line_chart_with_interpolation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/altair/examples/line_chart_with_interpolation.py b/altair/examples/line_chart_with_interpolation.py index 6e4d1bd9c..4da962337 100644 --- a/altair/examples/line_chart_with_interpolation.py +++ b/altair/examples/line_chart_with_interpolation.py @@ -7,9 +7,10 @@ import altair as alt from vega_datasets import data -source = data.wheat() +source = data.stocks() alt.Chart(source).mark_line(interpolate="monotone").encode( - x="year:O", - y="wheat:Q" -).properties(width=600) + x="date:T", + y="price:Q", + color="symbol:N" +) From be45ec56541bf4c4417dec4e39fe44e283bf7f78 Mon Sep 17 00:00:00 2001 From: Ben Welsh Date: Tue, 5 Jul 2022 14:15:51 -0700 Subject: [PATCH 8/8] Delete line_chart_with_stroked_points.py --- .../line_chart_with_stroked_points.py | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 altair/examples/line_chart_with_stroked_points.py diff --git a/altair/examples/line_chart_with_stroked_points.py b/altair/examples/line_chart_with_stroked_points.py deleted file mode 100644 index bf8ec89bd..000000000 --- a/altair/examples/line_chart_with_stroked_points.py +++ /dev/null @@ -1,21 +0,0 @@ -""" -Line Chart with Stroked Points ------------------------------- -This chart shows a line chart with stroked points marking each value. -""" -# category: line charts -import altair as alt -from vega_datasets import data - -source = data.wheat() - -base = alt.Chart(source).encode( - x="year:O", - y="wheat:Q" -) - -line = base.mark_line() - -point = base.mark_point(fill="white", stroke="steelblue") - -(line + point).properties(width=600)