Basemap / mplot3d mashup

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Basemap / mplot3d mashup

Benjamin Root
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!

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

basemap_mplot3d_mashup.png (96K) Download Attachment
Loading...