Link to JakeVDP's presentation: https://speakerdeck.com/jakevdp/altair-declarative-visualization-in-python-dse-summit-2016
import altair
altair.tutorial()
Copying notebooks into fresh tutorial directory: ./AltairTutorial Click on the following notebooks to explore the tutorial:
from altair import datasets
datasets.list_datasets()
['flights-airport', 'wheat', 'unemployment-across-industries', 'gapminder', 'stocks', 'burtin', 'gapminder-health-income', 'world-110m', 'weball26', 'points', 'monarchs', 'airports', 'flare', 'seattle-weather', 'flights-3m', 'climate', 'driving', 'seattle-temps', 'jobs', 'barley', 'cars', 'budgets', 'crimea', 'budget', 'population', 'github', 'weather', 'anscombe', 'us-10m', 'miserables', 'birdstrikes', 'countries', 'movies', 'flights-10k', 'sf-temps', 'iris', 'flights-20k', 'flights-5k', 'sp500', 'flights-2k']
cars = datasets.load_dataset('cars')
cars.head()
Acceleration | Cylinders | Displacement | Horsepower | Miles_per_Gallon | Name | Origin | Weight_in_lbs | Year | |
---|---|---|---|---|---|---|---|---|---|
0 | 12.0 | 8 | 307.0 | 130.0 | 18.0 | chevrolet chevelle malibu | USA | 3504 | 1970-01-01 |
1 | 11.5 | 8 | 350.0 | 165.0 | 15.0 | buick skylark 320 | USA | 3693 | 1970-01-01 |
2 | 11.0 | 8 | 318.0 | 150.0 | 18.0 | plymouth satellite | USA | 3436 | 1970-01-01 |
3 | 12.0 | 8 | 304.0 | 150.0 | 16.0 | amc rebel sst | USA | 3433 | 1970-01-01 |
4 | 10.5 | 8 | 302.0 | 140.0 | 17.0 | ford torino | USA | 3449 | 1970-01-01 |
from altair import Chart
Chart(cars).mark_circle().encode(x='Weight_in_lbs', y='Horsepower', color='Origin')
Chart(cars).mark_circle().encode(x='Weight_in_lbs', y='Horsepower', color='Cylinders:N')
Chart(cars).mark_circle().encode(x='Weight_in_lbs', y='Horsepower', color='Origin')
Chart(cars).mark_circle().encode(x='Weight_in_lbs', y='Horsepower', color='Cylinders', row='Origin').configure_cell(height=150)