Thank you for your ideas, I leave the correct code to plot trajectories of any
object, in my case I have drawn the trajectories of convective storms.
1. # --- Construimos el mapa ---
2.
3. import numpy as np
4. from mpl_toolkits.basemap import Basemap
5. import matplotlib.pyplot as plt
6. from PIL import *
7. fig = plt.figure(figsize=(12,12))
8.
9. ax = fig.add_axes([0.1,0.1,0.8,0.8])
10.
11. m = Basemap(projection='cyl', llcrnrlat=12, urcrnrlat=35,llcrnrlon=-120,
urcrnrlon=-80, resolution='c', area_thresh=1000.)
12.
13. m.bluemarble()
14. m.drawcoastlines(linewidth=0.5)
15. m.drawcountries(linewidth=0.5)
16. m.drawstates(linewidth=0.5)
17.
18. # --- Dibujamos paralelos y meridianos ---
19.
20. m.drawparallels(np.arange(10.,35.,5.),labels=[1,0,0,1])
21. m.drawmeridians(np.arange(-120.,-80.,5.),labels=[1,0,0,1])
22. m.drawmapboundary(fill_color='aqua')
23.
24. # --- Abrimos el archivo que contiene los datos ---
25.
26. import pandas as pd
27.
28. df = pd.read_csv('scm-2004.csv')
29. for evento, group in df.groupby(['evento']):
30. latitude = group.lat.values
31. longitude = group.lon.values
32. x,y = m(longitude, latitude)
33. plt.plot(x,y,'y-',linewidth=2 )
34. plt.xlabel('Longitud')
35. plt.ylabel('Latitud')
36. plt.title('Trayectorias de Sistemas Convectivos 2004')
37.
38.
39.
40. plt.savefig('track-2004.jpg', dpi=100)
With the above code, I get the desired figure. 60 paths drawn on the map of
México.
I have only one last question: how could indicate the start of each of the
storms, someone has an idea how I can do this?
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users