I have three variables that I need to plot for sales transactions, timestamp
(of the sale), price
, and zip_code
. Is there a python or javascript library where I could plot a heat map with these variables? Perhaps something similar to HighCharts, but with geographical plotting.
Matplotlib is a great Python plotting library. It has geographical plotting abilities using the basemap toolkit. However, I don't think it has information on zip code boundaries, so you would have to get ZIP code shapefiles from somewhere. Googling suggests they may be available from the US Census website.
I'm not aware of any Python plotting toolkit that supports ZIP code-based mapping out of the box. What matplotlib with basemap allows you to do is plot ordinary markers (dots, shapes, etc.) onto a map. It would be easy, for instance, to plot a map with colored dots (with colors "heatmapped" corresponding to transaction price, say) across a map of the USA. It seems like the hard part of what you want is getting map data that includes information about ZIP code boundaries. I'm pretty sure you could get matplotlib to work, but it could take some setup work to get that ZIP code information hooked up in the right way.
I would do it like this:
First, download the US Census Bureau shapefile Second, plot the shapes in matplotlib
Here is a gist on how to download zip code shapefiles and how to use the files to draw a map. It also shows you how to vary the color of individual zipcodes.
You would scale the datapoints you're looking for, then either use the grayscale percentages or RGB tuple to vary the color by zip code.