%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (10.0, 6.0)
Get hold of the actual data:
# Downloaded from http://www.volcano.si.edu/list_volcano_excel.cfm
# and converted to CSV.
from matplotlib.pylab import csv2rec
gvp = csv2rec('/downloads/GVP_Volcano_List.csv', skiprows=1)
print gvp.size, gvp.longitude, gvp.latitude
1550 [ 6.85 2.97 2.53 ..., -28.14 -27.57 -28.246] [ 50.17 45.775 42.17 ..., -56.656 -56.3 -56.014]
Now that we have the data, we set up a map with the projection keyword, and add the data with the transform keyword (important!):
import cartopy.crs as ccrs
ax = plt.axes(projection=ccrs.PlateCarree())
plt.plot(gvp.longitude, gvp.latitude, '^r', transform=ccrs.Geodetic())
ax.stock_img()
plt.show()
Because we can define the projection and transform independently, we can now change the underlying map without having to touch the data coordinates, so let's define a function which produces the axes for us, and draw a map with a different central longitude:
def draw_volcanoes(projection):
ax = plt.axes(projection=projection)
plt.plot(gvp.longitude, gvp.latitude, '^r', transform=ccrs.Geodetic())
ax.stock_img()
return ax
draw_volcanoes(ccrs.PlateCarree(central_longitude=180))
plt.show()
We can specify any valid cartopy projection (http://scitools.org.uk/cartopy/docs/latest/crs/projections.html), and the data is placed accordingly:
draw_volcanoes(ccrs.InterruptedGoodeHomolosine())
plt.show()