Event box

Visualization in Python with Altair

[Online] While Python is my preferred programming language for scripted data transformations, I have avoided routinely doing data visualization in Python. I could follow examples for the many Python visualization libraries, but in the end they all seemed confusing and made it hard to do the types of exploratory visualization that Tableau made easy. Finally, Altair has emerged as a viable alternative for me, because of the way it "thinks about" data and the visualization process.

Altair is a declarative statistical visualization library for Python, built on top of the well-design and powerful Vega-Lite visualization grammar. (Vega-lite was built for the web, includes interaction, and is being adopted as a standard by high profile websites and tools.) It works well for small to medium-sized tabular data (like spreadsheets). 

In this workshop, I’ll run you through both some introductory and some more complex examples using Altair with Python in Jupyter notebooks, so you can get a feeling for how you might use it in your own work. 

Note: This is an introductory workshop on Altair, but you’ll probably be more comfortable following along if you have at least a little bit of experience using the Python programming language, since I won’t be spending time on the language itself. (Feel free to sign up no matter what your experience level, but past students with no Python or programming experience have found it too confusing to be useful.) 

Install the Anaconda Python distribution (Individual Edition): 
https://www.anaconda.com/products/individual

I strongly recommend that you install the Anaconda Python Distribution to use in class. In principle, if you have something above Python 3.7 or so, plus all the necessary modules, everything should work fine. But, the Anaconda Distribution is packaged nicely, can be installed without admin privileges, and comes with everything you’ll need. If you have another version of Python already installed and you’re going to install Anaconda, it’s best to uninstall the other version first. It can get to be a mess if you have multiple versions of Python installed on one machine. 

  • Go to the link above, hit Download, and choose the version for your operating system. I would recommend to just install for “yourself”, not for all users of the machine, since that way it will install everything in your Users/username folder and doesn’t require admin privileges. 
  • If you’re on Mac and aren’t comfortable with shell scripts on the command line, choose the Graphical Installer. 
  • On Windows, I would choose the 64-bit installer, unless you know you’re still running a 32-bit version of Windows on an older machine. 
  • If you’re sticking with your non-Anaconda version of Python, make sure you have JupyterLab, Pandas, Altair, and all of their respective dependencies installed.

Please try to launch Python and JupyterLab before class to make sure they’re working! JupyterLab can be started from the Anaconda Navigator application, or from the Anaconda Prompt (Windows) or a Terminal (Mac) by typing (without quotes) “jupyter lab” and hitting return. From a Python notebook or an interactive Python prompt, you can test out the main modules you’ll need by typing this and executing the code cell:

import pandas as pd
import altair as alt

The content of the workshop may be recorded. If you are uncomfortable with a recording being published, please contact the instructor at any time prior to the conclusion of the workshop.

Data Visualization

Date:
Wednesday, October 6, 2021
Time:
10:00am - 12:00pm
Campus:
n/a
Categories:
Data and Visualization  
Registration has closed.

Event Organizer

Eric Monson
Profile photo of Center for Data and Visualization Sciences
Center for Data and Visualization Sciences