Basemap / mplot3d mashup

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

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(ret4 = bm.drawcountries())

Still a bit buggy. The lakes, states and countries aren't showing up, but it is a start!

Matplotlib-users mailing list
[hidden email]

basemap_mplot3d_mashup.png (96K) Download Attachment