4

I have been creating choropleth maps in Python by adding patches and/or polygons in a matplotlib Axes but I'm looking for something easier to use.

Ideally, the interface should be similar to how contour maps or pseudocolor plots are created where, at the minimum, only one call to a function is needed to create these plots from data. Colors are automatically assigned and normalized based on values. A colorbar can then be added by calling another function.

So far, the closest package seems to be geopandas. Is there an another package that is nearer to what I want? That is, is there a package that can make a (basic) chloropleth of values stored as a dictionary, numpy array or pandas dataframe in one call? The final output is eventually a static image (for publication).

I'm willing to contribute code and help develop the chloropleth capability of a package since I currently end up creating my own function and manipulating Axes internals just to create a choropleth.

A choropleth map is something like this (example from Wikipedia) but the labels may be omitted: enter image description here

  • If I understand correctly, you want something similar to pcolormesh in matplotlib but applied on a geographical map with numbered regions instead of axes? Couldn't it be done using surfaces in Pygame? – Tymric Oct 24 '14 at 15:32
  • 1
    Yes, your understanding is correct. I edited the question to add an example. I think using Pygame surfaces would be more laborious that what I'm doing now with matplotlib, unfortunately. – Christian Alis Oct 24 '14 at 17:05
1

Bokeh Icon

Try Bokeh.

The Texas Unemployment 2009 map from their examples gallery looks pretty close to what you are looking for.

It looks like the key function is:

bokeh.plotting.patches(xs, ys, **kwargs)


Texas Unemployment 2009 map

  • This certainly looks interesting but the intended output is a static image and I feel bokeh is a roundabout way of doing that. I guess I'll just help in improving geopandas but I'll accept your answer because it fits my (unedited) specs. – Christian Alis Oct 31 '14 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.