
Untitled
By: a guest on
Sep 29th, 2011 | syntax:
Python | size: 0.83 KB | hits: 107 | expires: Never
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
from mpl_toolkits.basemap import Basemap
# Setup map projection.
ulat, llat, ulon, llon = 07., -35., -32., -77.
fig = plt.figure()
map = Basemap(projection='merc', llcrnrlat=llat,
urcrnrlat=ulat,
llcrnrlon=llon,
urcrnrlon=ulon,
resolution='i')
shp = map.readshapefile('/usr/share/basemap/brazil', 'states', drawbounds=True)
map.fillcontinents()
map.drawparallels([-34, 05], linewidth=0, labels=[1,0,0,1])
map.drawmeridians([llon, ulon], linewidth=0, labels=[1,0,0,1])
ax = plt.gca()
for nshape,seg in enumerate(map.states):
poly = Polygon(seg,facecolor='.75',edgecolor='k')
ax.add_patch(poly)
plt.show()