Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 29th, 2011  |  syntax: Python  |  size: 0.83 KB  |  views: 117  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import matplotlib.pyplot as plt
  2. from matplotlib.patches import Polygon
  3. from mpl_toolkits.basemap import Basemap
  4.  
  5. # Setup map projection.
  6. ulat, llat, ulon, llon =  07., -35., -32., -77.
  7.  
  8. fig = plt.figure()
  9. map = Basemap(projection='merc', llcrnrlat=llat,
  10.                                  urcrnrlat=ulat,
  11.                                  llcrnrlon=llon,
  12.                                  urcrnrlon=ulon,
  13.                                  resolution='i')
  14.  
  15. shp = map.readshapefile('/usr/share/basemap/brazil', 'states', drawbounds=True)
  16. map.fillcontinents()
  17.  
  18. map.drawparallels([-34, 05], linewidth=0, labels=[1,0,0,1])
  19. map.drawmeridians([llon, ulon], linewidth=0, labels=[1,0,0,1])
  20.  
  21. ax = plt.gca()
  22. for nshape,seg in enumerate(map.states):
  23.       poly = Polygon(seg,facecolor='.75',edgecolor='k')
  24.       ax.add_patch(poly)
  25.  
  26. plt.show()
  27.  
clone this paste RAW Paste Data