2013/2/12 Boris Vladimir Comi <gle...@comunidad.unam.mx>

>  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?
>

Una pregunta, ¿por qué hablas en inglés en la lista de python en español?

Respecto a tu pregunta, puedes dibujar solo el punto inicial de la
trayectoria usando plt.plot o plt.scatter con x[0] e y[0] cambiando el
color de ese punto o el marcador que se usa para la trayectoria teniendo un
marcador diferente para el origen de la tormenta. Este plt.plot o plt.
scatter deberías usarlo después del plt.plot que usas para la trayectoria
completa para que se dibuje por encima de ella.

Saludos.
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a