-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2626 from palewire/patch-4
Tidy Falkensee case study
- Loading branch information
Showing
1 changed file
with
58 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,77 @@ | ||
""" | ||
Falkensee | ||
----------------------- | ||
This example is a reproduction of the Falkensee plot found in the vega-lite examples. | ||
Population of Falkensee from 1875 to 2014 | ||
----------------------------------------- | ||
This example is a reproduction of the Falkensee plot found in the Vega-Lite examples. | ||
""" | ||
# category: case studies | ||
import altair as alt | ||
|
||
source = [ | ||
{"year": "1875", "population": 1309}, | ||
{"year": "1890", "population": 1558}, | ||
{"year": "1910", "population": 4512}, | ||
{"year": "1925", "population": 8180}, | ||
{"year": "1933", "population": 15915}, | ||
{"year": "1939", "population": 24824}, | ||
{"year": "1946", "population": 28275}, | ||
{"year": "1950", "population": 29189}, | ||
{"year": "1964", "population": 29881}, | ||
{"year": "1971", "population": 26007}, | ||
{"year": "1981", "population": 24029}, | ||
{"year": "1985", "population": 23340}, | ||
{"year": "1989", "population": 22307}, | ||
{"year": "1990", "population": 22087}, | ||
{"year": "1991", "population": 22139}, | ||
{"year": "1992", "population": 22105}, | ||
{"year": "1993", "population": 22242}, | ||
{"year": "1994", "population": 22801}, | ||
{"year": "1995", "population": 24273}, | ||
{"year": "1996", "population": 25640}, | ||
{"year": "1997", "population": 27393}, | ||
{"year": "1998", "population": 29505}, | ||
{"year": "1999", "population": 32124}, | ||
{"year": "2000", "population": 33791}, | ||
{"year": "2001", "population": 35297}, | ||
{"year": "2002", "population": 36179}, | ||
{"year": "2003", "population": 36829}, | ||
{"year": "2004", "population": 37493}, | ||
{"year": "2005", "population": 38376}, | ||
{"year": "2006", "population": 39008}, | ||
{"year": "2007", "population": 39366}, | ||
{"year": "2008", "population": 39821}, | ||
{"year": "2009", "population": 40179}, | ||
{"year": "2010", "population": 40511}, | ||
{"year": "2011", "population": 40465}, | ||
{"year": "2012", "population": 40905}, | ||
{"year": "2013", "population": 41258}, | ||
{"year": "2014", "population": 41777} | ||
] | ||
{"year": "1875", "population": 1309}, | ||
{"year": "1890", "population": 1558}, | ||
{"year": "1910", "population": 4512}, | ||
{"year": "1925", "population": 8180}, | ||
{"year": "1933", "population": 15915}, | ||
{"year": "1939", "population": 24824}, | ||
{"year": "1946", "population": 28275}, | ||
{"year": "1950", "population": 29189}, | ||
{"year": "1964", "population": 29881}, | ||
{"year": "1971", "population": 26007}, | ||
{"year": "1981", "population": 24029}, | ||
{"year": "1985", "population": 23340}, | ||
{"year": "1989", "population": 22307}, | ||
{"year": "1990", "population": 22087}, | ||
{"year": "1991", "population": 22139}, | ||
{"year": "1992", "population": 22105}, | ||
{"year": "1993", "population": 22242}, | ||
{"year": "1994", "population": 22801}, | ||
{"year": "1995", "population": 24273}, | ||
{"year": "1996", "population": 25640}, | ||
{"year": "1997", "population": 27393}, | ||
{"year": "1998", "population": 29505}, | ||
{"year": "1999", "population": 32124}, | ||
{"year": "2000", "population": 33791}, | ||
{"year": "2001", "population": 35297}, | ||
{"year": "2002", "population": 36179}, | ||
{"year": "2003", "population": 36829}, | ||
{"year": "2004", "population": 37493}, | ||
{"year": "2005", "population": 38376}, | ||
{"year": "2006", "population": 39008}, | ||
{"year": "2007", "population": 39366}, | ||
{"year": "2008", "population": 39821}, | ||
{"year": "2009", "population": 40179}, | ||
{"year": "2010", "population": 40511}, | ||
{"year": "2011", "population": 40465}, | ||
{"year": "2012", "population": 40905}, | ||
{"year": "2013", "population": 41258}, | ||
{"year": "2014", "population": 41777}, | ||
] | ||
|
||
source2 = [{ | ||
"start": "1933", | ||
"end": "1945", | ||
"event": "Nazi Rule" | ||
}, | ||
{ | ||
"start": "1948", | ||
"end": "1989", | ||
"event": "GDR (East Germany)" | ||
}] | ||
source2 = [ | ||
{"start": "1933", "end": "1945", "event": "Nazi Rule"}, | ||
{"start": "1948", "end": "1989", "event": "GDR (East Germany)"}, | ||
] | ||
|
||
|
||
source = alt.pd.DataFrame(source) | ||
source2 = alt.pd.DataFrame(source2) | ||
|
||
|
||
line = alt.Chart(source).mark_line(color='#333').encode( | ||
alt.X('year:T', axis=alt.Axis(format='%Y')), | ||
y='population' | ||
).properties( | ||
width=500, | ||
height=300 | ||
line = alt.Chart(source).mark_line(color="#333").encode( | ||
x=alt.X("year:T", axis=alt.Axis(format="%Y"), title="Year"), | ||
y=alt.Y("population", title="Population"), | ||
) | ||
|
||
point = line.mark_point(color='#333') | ||
point = line.mark_point(color="#333") | ||
|
||
rect = alt.Chart(source2).mark_rect().encode( | ||
x='start:T', | ||
x2='end:T', | ||
color='event:N' | ||
x="start:T", | ||
x2="end:T", | ||
color=alt.Color("event:N", title="Event") | ||
) | ||
|
||
rect + line + point | ||
(rect + line + point).properties( | ||
title="Population of Falkensee from 1875 to 2014", | ||
width=500, | ||
height=300 | ||
) |