Thank you for your ideas, I leave the correct code for constructing the trajectories of any object, in my case I drew the trajectories of convective storms.
import numpy as np from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt fig = plt.figure(figsize=(12,12)) ax = fig.add_axes([0.1,0.1,0.8,0.8]) m = Basemap(projection='cyl', llcrnrlat=12, urcrnrlat=35,llcrnrlon=-120, urcrnrlon=-80, resolution='c', area_thresh=1000.) m.bluemarble() m.drawcoastlines(linewidth=0.5) m.drawcountries(linewidth=0.5) m.drawstates(linewidth=0.5)
--- Dibujamos paralelos y meridianos ---
m.drawparallels(np.arange(10.,35.,5.),labels=[1,0,0,1]) m.drawmeridians(np.arange(-120.,-80.,5.),labels=[1,0,0,1]) m.drawmapboundary(fill_color='aqua')
--- Abrimos el archivo que contiene los datos ---
import pandas as pd df = pd.read_csv('scm-2004.csv') for evento, group in df.groupby(['evento']): latitude = group.lat.values longitude = group.lon.values x,y = m(longitude, latitude) plt.plot(x,y,'y-',linewidth=2 ) plt.xlabel('Longitud') plt.ylabel('Latitud') plt.title('Trayectorias de Sistemas Convectivos 2004') plt.savefig('track-2004.jpg', dpi=100)
With the code above, I get the desired number: 60 tracks drawn on a map of Mexico. I have only one last question: how to indicate the beginning of each of the storms, someone has an idea, how can I do this?
When I told him to write “Longitud” along the X axis (xlabel = 'Latitude'), overwrites the word by length values, how can I write a word under latitude values?