[Matplotlib-users] Basemap / mplot3d mashup

Benjamin Root ben.v.root at gmail.com
Fri Aug 11 13:13:02 EDT 2017


For the longest time, I have avoided trying to combine Basemap and mplot3d
because I knew that they both predated the transforms system and that they
wouldn't be able to properly work together. However, today, I looked at the
problem differently for some reason and realized that it might actually be
possible for them to work together in a hacky sort of way.

```
from mpl_toolkits.basemap import Basemap
from mpl_toolkits.mplot3d import axes3d, art3d
from matplotlib import pyplot as plt

fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
bm = Basemap(projection='merc', lat_0=57, lon_0=-135, resolution='l',
                        llcrnrlon=-130, llcrnrlat=20, urcrnrlon=-65,
urcrnrlat=55)

map(art3d.patch_2d_to_3d, bm.fillcontinents(color='wheat',
lake_color='aqua'))
art3d.line_collection_2d_to_3d(art3d.bm.drawcoastlines())
art3d.line_collection_2d_to_3d(bm.drawstates())
art3d.line_collection_2d_to_3d(ret4 = bm.drawcountries())

plt.show()
```

Still a bit buggy. The lakes, states and countries aren't showing up, but
it is a start!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170811/87e5391d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: basemap_mplot3d_mashup.png
Type: image/png
Size: 72568 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170811/87e5391d/attachment-0001.png>


More information about the Matplotlib-users mailing list