CoCalc Shared Filesbasemap.ipynbOpen in CoCalc with one click!
Authors: Harald Schilly, ℏal Snyder
Views : 39

Basemap in Python 2 (Ubuntu Linux)

In [2]:
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap austin = (-97.75, 30.25) hawaii = (-157.8, 21.3) washington = (-77.01, 38.90) chicago = (-87.68, 41.83) losangeles = (-118.25, 34.05) m = Basemap(projection = 'merc', llcrnrlat=10, urcrnrlat=50, llcrnrlon=-160, urcrnrlon=-60) m.drawcoastlines() m.fillcontinents (color='lightgray', lake_color='lightblue') m.drawparallels(np.arange(-90.,91.,30.)) m.drawmeridians(np.arange(-180.,181.,60.)) m.drawmapboundary(fill_color='aqua') m.drawcounties() x, y = m(*zip(*[hawaii, austin, washington, chicago, losangeles])) m.plot(x,y, marker ='o', markersize=6, markerfacecolor='red', linewidth=0) plt.title('Mercator Projection') plt.show()
/usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap/__init__.py:1704: MatplotlibDeprecationWarning: The axesPatch function was deprecated in version 2.1. Use Axes.patch instead. limb = ax.axesPatch /usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap/__init__.py:1707: MatplotlibDeprecationWarning: The axesPatch function was deprecated in version 2.1. Use Axes.patch instead. if limb is not ax.axesPatch:
In [7]:
import mpl_toolkits from mpl_toolkits.basemap import Basemap b = Basemap(projection = 'merc') assert type(b) == mpl_toolkits.basemap.Basemap assert b is not None
In [ ]: