updating contours

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon

···

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151023/607fd5b2/attachment.html>

You're correct that there is no equivalent -- contour is one of those
"computed" things that can't be directly updated from the original data.
You don't need to do a whole `cla()` though. Removing the contour artist
and calling contour again should be sufficient.

Mike

···

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151026/6fc1b45a/attachment.html>

Hi Mike,

Yes, that's basically what I ended up doing. I did
ax.collections.pop()
ax.contour(...)

I'm not sure if there's a different (better?) way to remove the contours,
but that works.

By the way, it was not easy to discover that contours are collections (a
LineCollection), though I guess it's not too hard to guess. I think the
docs could provide more information along these lines.

Jon

···

On Mon, Oct 26, 2015 at 11:07 AM, Michael Droettboom < mdroettboom at continuum.io> wrote:

You're correct that there is no equivalent -- contour is one of those
"computed" things that can't be directly updated from the original data.
You don't need to do a whole `cla()` though. Removing the contour artist
and calling contour again should be sufficient.

Mike

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan < > jslavin at cfa.harvard.edu> wrote:

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151026/6f06c2f3/attachment.html>

If you only need (a lot of) contours on (a lot of) images, vispy or glumpy might be an option (they both use GPU to compute contours).
See for example: http://glumpy.github.io/_static/screenshots/isocurves.png

Nicolas

···

On 26 Oct 2015, at 16:07, Michael Droettboom <mdroettboom at continuum.io> wrote:

You're correct that there is no equivalent -- contour is one of those "computed" things that can't be directly updated from the original data. You don't need to do a whole `cla()` though. Removing the contour artist and calling contour again should be sufficient.

Mike

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:
Hi,

I'm looking at a series of images and want to include overplotted contours. To update the image I just need to use the set_data() method of the AxesImage object. However, as far as I can tell, there's nothing similar for the QuadContourSet object. I tried set_array() but that didn't work. Am I missing something? Does anyone have any suggestions for how to update the contours? Of course if necessary I could do a cla(), but that would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

Please don't do ax.collections.pop(), it is better to keep a reference to
the object returned by contour and then using its remove method.

The second way is safer as you will always remove the artist you think you
are removing and more future proof as the lists of artists (lines,
collections, ...) really should be considered internal details of mpl and
not accessed directly.

Tom

···

On Tue, Oct 27, 2015, 01:38 Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Hi Mike,

Yes, that's basically what I ended up doing. I did
ax.collections.pop()
ax.contour(...)

I'm not sure if there's a different (better?) way to remove the contours,
but that works.

By the way, it was not easy to discover that contours are collections (a
LineCollection), though I guess it's not too hard to guess. I think the
docs could provide more information along these lines.

Jon

On Mon, Oct 26, 2015 at 11:07 AM, Michael Droettboom < > mdroettboom at continuum.io> wrote:

You're correct that there is no equivalent -- contour is one of those
"computed" things that can't be directly updated from the original data.
You don't need to do a whole `cla()` though. Removing the contour artist
and calling contour again should be sufficient.

Mike

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan < >> jslavin at cfa.harvard.edu> wrote:

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151027/7b85da3b/attachment.html>

Do you think it's worthy of a bug report? It's not clear to me that the
collections of the AxesSubplot should be considered as internal, though I
do think that QuadContourSet objects should have a remove method in the
same way that AxesImage and Line2D objects have.

Jon

···

On Tue, Oct 27, 2015 at 9:06 AM, Thomas Caswell <tcaswell at gmail.com> wrote:

That is a bug in something...

On Tue, Oct 27, 2015, 08:53 Slavin, Jonathan <jslavin at cfa.harvard.edu> > wrote:

Tom,

Do you mean something like:
cs = ax.contour(...)
.
.
.
cs.remove()
If so, that doesn't work:
AttributeError: QuadContourSet instance has no attribute 'remove'

Jon

On Tue, Oct 27, 2015 at 7:48 AM, Thomas Caswell <tcaswell at gmail.com> >> wrote:

Please don't do ax.collections.pop(), it is better to keep a reference
to the object returned by contour and then using its remove method.

The second way is safer as you will always remove the artist you think
you are removing and more future proof as the lists of artists (lines,
collections, ...) really should be considered internal details of mpl and
not accessed directly.

Tom

On Tue, Oct 27, 2015, 01:38 Slavin, Jonathan <jslavin at cfa.harvard.edu> >>> wrote:

Hi Mike,

Yes, that's basically what I ended up doing. I did
ax.collections.pop()
ax.contour(...)

I'm not sure if there's a different (better?) way to remove the
contours, but that works.

By the way, it was not easy to discover that contours are collections
(a LineCollection), though I guess it's not too hard to guess. I think the
docs could provide more information along these lines.

Jon

On Mon, Oct 26, 2015 at 11:07 AM, Michael Droettboom < >>>> mdroettboom at continuum.io> wrote:

You're correct that there is no equivalent -- contour is one of those
"computed" things that can't be directly updated from the original data.
You don't need to do a whole `cla()` though. Removing the contour artist
and calling contour again should be sufficient.

Mike

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan < >>>>> jslavin at cfa.harvard.edu> wrote:

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151027/be54148c/attachment-0001.html>

Yes, please make a bug report.

I agree that it is not clear that collections is internal, but it _should_
be, that is a detail of how mpl stores the artists that need to be rendered
at draw time.

Because we store lines and collections in separate lists that get merged
and sorted based on z-order during the draw process we can get some
pathological rendering errors where errorbars have inconsistent layering.
In the near-ish (year?) there is likely to be a major refactoring to how
artists are stored internally to merge them into a single data structure.
We will provide back-compatible shims, but those will go away eventually so
the less code reaching in and touching them the better.

Tom

···

On Tue, Oct 27, 2015 at 9:49 AM Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Do you think it's worthy of a bug report? It's not clear to me that the
collections of the AxesSubplot should be considered as internal, though I
do think that QuadContourSet objects should have a remove method in the
same way that AxesImage and Line2D objects have.

Jon

On Tue, Oct 27, 2015 at 9:06 AM, Thomas Caswell <tcaswell at gmail.com> > wrote:

That is a bug in something...

On Tue, Oct 27, 2015, 08:53 Slavin, Jonathan <jslavin at cfa.harvard.edu> >> wrote:

Tom,

Do you mean something like:
cs = ax.contour(...)
.
.
.
cs.remove()
If so, that doesn't work:
AttributeError: QuadContourSet instance has no attribute 'remove'

Jon

On Tue, Oct 27, 2015 at 7:48 AM, Thomas Caswell <tcaswell at gmail.com> >>> wrote:

Please don't do ax.collections.pop(), it is better to keep a reference
to the object returned by contour and then using its remove method.

The second way is safer as you will always remove the artist you think
you are removing and more future proof as the lists of artists (lines,
collections, ...) really should be considered internal details of mpl and
not accessed directly.

Tom

On Tue, Oct 27, 2015, 01:38 Slavin, Jonathan <jslavin at cfa.harvard.edu> >>>> wrote:

Hi Mike,

Yes, that's basically what I ended up doing. I did
ax.collections.pop()
ax.contour(...)

I'm not sure if there's a different (better?) way to remove the
contours, but that works.

By the way, it was not easy to discover that contours are collections
(a LineCollection), though I guess it's not too hard to guess. I think the
docs could provide more information along these lines.

Jon

On Mon, Oct 26, 2015 at 11:07 AM, Michael Droettboom < >>>>> mdroettboom at continuum.io> wrote:

You're correct that there is no equivalent -- contour is one of those
"computed" things that can't be directly updated from the original data.
You don't need to do a whole `cla()` though. Removing the contour artist
and calling contour again should be sufficient.

Mike

On Fri, Oct 23, 2015 at 11:56 AM, Slavin, Jonathan < >>>>>> jslavin at cfa.harvard.edu> wrote:

Hi,

I'm looking at a series of images and want to include overplotted
contours. To update the image I just need to use the set_data() method of
the AxesImage object. However, as far as I can tell, there's nothing
similar for the QuadContourSet object. I tried set_array() but that didn't
work. Am I missing something? Does anyone have any suggestions for how to
update the contours? Of course if necessary I could do a cla(), but that
would be slow, I think.

Regards,
Jon
--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Michael Droettboom
Continuum Analytics

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

--
________________________________________________________
Jonathan D. Slavin Harvard-Smithsonian CfA
jslavin at cfa.harvard.edu 60 Garden Street, MS 83
phone: (617) 496-7981 Cambridge, MA 02138-1516
cell: (781) 363-0035 USA
________________________________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151027/91ce2581/attachment.html>