Altair is the best graphing software even made, but right now there’s an open bug that prevents me from really recommending it to you. It’s incredible, though, and the LA Times uses it a lot I think.
Making charts of categorical vs. categorical data
Let’s say we have some crimes that occur across different months.
murder | theft | burglary | month | |
---|---|---|---|---|
0 | 1 | 4 | 6 | January |
1 | 2 | 5 | 4 | February |
2 | 3 | 4 | 3 | March |
Most graphing software needs this to be long data, not wide data, so we’ll melt it.
month | crime_type | crime_count | |
---|---|---|---|
0 | January | murder | 1 |
1 | February | murder | 2 |
2 | March | murder | 3 |
3 | January | theft | 4 |
4 | February | theft | 5 |
5 | March | theft | 4 |
6 | January | burglary | 6 |
7 | February | burglary | 4 |
8 | March | burglary | 3 |
Now we can use altair to graph each point. Our X axis is going to be the month,
and our Y axis is going to be the crime type. We’ll use crime_count
for the
size of each circle.
You’ll need to pip install vega
and pip install altair
before this
<vega.vegalite.VegaLite at 0x115b31e80>
Now we can save it, too.