Removing Markers from Figure

Greetings,

I'm needing to create two plots, one is to serve as an overlay on the
other. The overlay contains a set of markers to identify points in
the underlaid probability field. I'm doing this in a loop with a map
background, so to prevent redrawing the map every time, I want to
remove the markers after saving the plot (so I can then reuse the
background again). I know how to remove contours, but cannot figure
out how to remove points. Here is a link to a sample script that
illustrates the problem.

https://gist.github.com/072c8612f313e8ea2355

Ideally, I would expect each plot to have only a single point, but the
old points aren't being removed and are displayed on subsequent
images. What am I doing wrong?

Patrick

···

---
Patrick Marsh
Ph.D. Student / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com

Illustration with ipython -pylab:

In [1]: xx = plot(1.3, 2.4, 'ro')

In [2]: xx[0].remove()

In [3]: draw()

Note that plot() returns a list of Line2D objects, each of which has a remove() method.

Eric

···

On 05/27/2011 07:53 AM, Patrick Marsh wrote:

Greetings,

I'm needing to create two plots, one is to serve as an overlay on the
other. The overlay contains a set of markers to identify points in
the underlaid probability field. I'm doing this in a loop with a map
background, so to prevent redrawing the map every time, I want to
remove the markers after saving the plot (so I can then reuse the
background again). I know how to remove contours, but cannot figure
out how to remove points. Here is a link to a sample script that
illustrates the problem.

https://gist.github.com/072c8612f313e8ea2355

Ideally, I would expect each plot to have only a single point, but the
old points aren't being removed and are displayed on subsequent
images. What am I doing wrong?

Thanks, Eric!

I had tried

pt = plot(...)

for p in pt:
  p.remove()

and that did not do the trick. However, doing it the way you
suggested worked like a charm. Thanks!

Patrick

···

---
Patrick Marsh
Ph.D. Student / Liaison to the HWT
School of Meteorology / University of Oklahoma
Cooperative Institute for Mesoscale Meteorological Studies
National Severe Storms Laboratory
http://www.patricktmarsh.com

On Fri, May 27, 2011 at 2:57 PM, Eric Firing <efiring@...202...> wrote:

On 05/27/2011 07:53 AM, Patrick Marsh wrote:

Greetings,

I'm needing to create two plots, one is to serve as an overlay on the
other. The overlay contains a set of markers to identify points in
the underlaid probability field. I'm doing this in a loop with a map
background, so to prevent redrawing the map every time, I want to
remove the markers after saving the plot (so I can then reuse the
background again). I know how to remove contours, but cannot figure
out how to remove points. Here is a link to a sample script that
illustrates the problem.

https://gist.github.com/072c8612f313e8ea2355

Ideally, I would expect each plot to have only a single point, but the
old points aren't being removed and are displayed on subsequent
images. What am I doing wrong?

Illustration with ipython -pylab:

In [1]: xx = plot(1.3, 2.4, 'ro')

In [2]: xx[0].remove()

In [3]: draw()

Note that plot() returns a list of Line2D objects, each of which has a
remove() method.

Eric

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users