#!/usr/bin/env python import matplotlib.pyplot as plt # pyplot module import from mpl_toolkits.basemap import Basemap # basemap import import numpy as np # Numpy import # Cities names and coordinates cities = ['London', 'New York', 'Madrid', 'Cairo', 'Moscow', 'Delhi', 'Dakar'] lat = [51.507778, 40.716667, 40.4, 30.058, 55.751667, 28.61, 14.692778] lon = [-0.128056, -74, -3.683333, 31.229, 37.617778, 77.23, -17.446667] latLow = -90.0 latHigh = 90.0 lonLow = -180.0 lonHigh = 180.0 # orthogonal projection of the Earth #m = Basemap(projection='ortho', lat_0=45, lon_0=10) m = Basemap(projection='mill', llcrnrlat=latLow, urcrnrlat=latHigh, llcrnrlon=lonLow, urcrnrlon=lonHigh, resolution='c') # draw the borders of the map m.drawmapboundary() # draw the coasts borders and fill the continents m.drawcoastlines() m.fillcontinents() m.drawparallels(np.arange(latLow,latHigh+1,30.), labels=[True,False,False,False]) m.drawmeridians(np.arange(lonLow,lonHigh+1,80.), labels=[False,False,False,True]) # map city coordinates to map coordinates x, y = m(lon, lat) # draw a red dot at cities coordinates plt.plot(x, y, 'ro') for city, xc, yc in zip(cities, x, y): # draw the city name in a yellow (shaded) box plt.text(xc+250000, yc-150000, city, bbox=dict(facecolor='yellow', alpha=0.5)) # for each city, #for city, xc, yc in zip(cities, x, y): # # draw the city name in a yellow (shaded) box # plt.text(xc+250000, yc-150000, city, bbox=dict(facecolor='yellow', alpha=0.5)) # plt.savefig('fig_citiesOverMap.png') plt.show()