Fork or clone this repo to your computer. Make sure you have Python 3 and Pipenv installed on your computer.
Open this folder in your terminal and run pipenv install
. This may take a few minutes — among other things, it will install Pandas, Numpy, Jupyter, Jupyter Lab and, of course, Altair.
Once that's done, run pipenv shell
and then jupyter lab
. This should open up in your browser.
(Note: You should also be able to run this in a standard jupyter notebook
, but I haven't tested it there.)
The project data is in the data
directory. You can open the files right inside Jupyter Lab and check out how they're structured, or load them into your notebook with Pandas; the data definitions and sources are listed in that directory's readme.
Open up the fun-with-altair.ipynb
file. That's your working file; it's got all the libraries you'll need, the dataset imports and the prompts for what you'll do each step of the way. Run cells by hitting shift-enter
. Try to follow the prompts by looking at the Altair documentation and Googling. If you get stuck, I give you permission to open the fun-with-altair-SOLUTIONS.ipynb
notebook and peek, but try to make the charts before you do that!
- Link to this repo: bit.ly/nicar2019-altair-code
- Link to the session slides: bit.ly/nicar2019-altair-slides
- Check out the Altair documentation
- For more about the technology underneath Altair, here's the Vega-Lite documentation
- If you're ready to dive into more complex uses of Altair, this PyCon Altair Tutorial is a good place to start
- Here's how you can use Altair/Vega code with Flourish for a quick, embeddable interactive