updating a basemap

Hi

I see the example of updating a plot in examples/animation/gtk_timeout.py where the 2 lines

···

----
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
----

What is the equivalent when I want to update a Basemap with new latitudes and longitudes and I have done
m=Basemap(......)
m.plot(longitude_list,latitude_list)

Thanks
Mathew

Mathew Yeates wrote:

Hi

I see the example of updating a plot in examples/animation/gtk_timeout.py where the 2 lines
----
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
----

What is the equivalent when I want to update a Basemap with new latitudes and longitudes and I have done
m=Basemap(......)
m.plot(longitude_list,latitude_list)

Thanks
Mathew
  
Mathew: The Basemap plot method returns a list of matplotlib Line2d objects which you can use just as in the example.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

something isn't working
In my main routine I have
xpt,ypt= m(lons[0:500],lats[0:500])
outlines=m.plot(xpt,ypt,'r-') #m is my basemap, outlines is a list of size 1. Huh?

then in my update routine I have
counter=0
def update():
    global counter
    xpt,ypt= m(lons[counter*500:(counter+1)*500],lats[counter*500:(counter+1)*500])
    counter += 1
    outlines[0].set_data(xpt,ypt)
    canvas.draw_idle()
    return True

but this produces strange results. After a few iterations the line disappears completely. Is it wrong to use lists when I get xpt and ypt?

Mathew

Jeff Whitaker wrote:

···

Mathew Yeates wrote:

Hi

I see the example of updating a plot in examples/animation/gtk_timeout.py where the 2 lines
----
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
----

What is the equivalent when I want to update a Basemap with new latitudes and longitudes and I have done
m=Basemap(......)
m.plot(longitude_list,latitude_list)

Thanks
Mathew
  
Mathew: The Basemap plot method returns a list of matplotlib Line2d objects which you can use just as in the example.

-Jeff

Mathew Yeates wrote:

something isn't working
In my main routine I have
xpt,ypt= m(lons[0:500],lats[0:500])
outlines=m.plot(xpt,ypt,'r-') #m is my basemap, outlines is a list of size 1. Huh?

Mathew: It's one line, so the list has one Line2D object.

then in my update routine I have
counter=0
def update():
   global counter
   xpt,ypt= m(lons[counter*500:(counter+1)*500],lats[counter*500:(counter+1)*500])
   counter += 1
   outlines[0].set_data(xpt,ypt)
   canvas.draw_idle()
   return True

but this produces strange results. After a few iterations the line disappears completely. Is it wrong to use lists when I get xpt and ypt?

Mathew

Don't really understand what you're trying to do here, so I can't comment.

-Jeff

···

Jeff Whitaker wrote:

Mathew Yeates wrote:

Hi

I see the example of updating a plot in examples/animation/gtk_timeout.py where the 2 lines
----
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
----

What is the equivalent when I want to update a Basemap with new latitudes and longitudes and I have done
m=Basemap(......)
m.plot(longitude_list,latitude_list)

Thanks
Mathew
  
Mathew: The Basemap plot method returns a list of matplotlib Line2d objects which you can use just as in the example.

-Jeff

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

never mind. Got it working. One annoying thing, though, when the line reaches the edge of the figure, a line is drawn horizontally to the other side. This doesn't happen when I display all of the points at once.

Mathew

Mathew Yeates wrote:

···

something isn't working
In my main routine I have
xpt,ypt= m(lons[0:500],lats[0:500])
outlines=m.plot(xpt,ypt,'r-') #m is my basemap, outlines is a list of size 1. Huh?

then in my update routine I have
counter=0
def update():
    global counter
    xpt,ypt= m(lons[counter*500:(counter+1)*500],lats[counter*500:(counter+1)*500])
    counter += 1
    outlines[0].set_data(xpt,ypt)
    canvas.draw_idle()
    return True

but this produces strange results. After a few iterations the line disappears completely. Is it wrong to use lists when I get xpt and ypt?

Mathew

Jeff Whitaker wrote:
  

Mathew Yeates wrote:
    

Hi

I see the example of updating a plot in examples/animation/gtk_timeout.py where the 2 lines
----
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
----

What is the equivalent when I want to update a Basemap with new latitudes and longitudes and I have done
m=Basemap(......)
m.plot(longitude_list,latitude_list)

Thanks
Mathew
  

Mathew: The Basemap plot method returns a list of matplotlib Line2d objects which you can use just as in the example.

-Jeff

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users