duplicating a line object

Hi,

I have a plot on which I want to plot many points as open circles. I also
want to include a legend. The problem is that while a thin marker edge
width works very nicely for the plot, it is difficult to see in the
legend. My solution, which does work, is to define Line2D objects as proxy
artists and keep all the attributes the same except the mew, which I
increase. However, this seems error prone: if one changes attributes of
the line, then one has to also make those same changes to the proxy artist
line. I thought a better solution was to create the proxy artist as a
duplicate (copy) of the line and then change the mew via line.set_mew(n).
However, I haven't been able to figure out how to duplicate a Line2D
object. I tried copy and deepcopy from the python builtin copy module, but
those didn't work. Any help on this (including alternative ways of
approaching the problem) would be appreciated.

Thanks,
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/20151016/cf804d72/attachment.html>

Traitlets might be the solution here. You set up your proxy artist to have
properties that are linked to the properties of the plot object. When one
is updated, the other gets updated as well. The automatic linking of plot
objects to legend proxy artists is is one of the many benefits that would
come about with the future inclusion of traitlets in matplotlib. However, I
don't think you need to wait for us to get that aspect working. Since you
are already creating proxy artists, I think it shouldn't be that much more
effort to link their properties together with traitlets.

Unfortunately, the documentation is fairly sparse, and examples are minimal
as well. I know there was some decent examples during the SciPy tutorials,
but I can't seem to find it at the moment...

Ben Root

···

On Fri, Oct 16, 2015 at 10:10 AM, Slavin, Jonathan <jslavin at cfa.harvard.edu> wrote:

Hi,

I have a plot on which I want to plot many points as open circles. I also
want to include a legend. The problem is that while a thin marker edge
width works very nicely for the plot, it is difficult to see in the
legend. My solution, which does work, is to define Line2D objects as proxy
artists and keep all the attributes the same except the mew, which I
increase. However, this seems error prone: if one changes attributes of
the line, then one has to also make those same changes to the proxy artist
line. I thought a better solution was to create the proxy artist as a
duplicate (copy) of the line and then change the mew via line.set_mew(n).
However, I haven't been able to figure out how to duplicate a Line2D
object. I tried copy and deepcopy from the python builtin copy module, but
those didn't work. Any help on this (including alternative ways of
approaching the problem) would be appreciated.

Thanks,
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
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20151016/e94c2a1e/attachment.html&gt;

Hi Ben,

Hmm, traitlets sound interesting, though I want one of the traits (i.e. the
marker edge width) to differ.

Actually, it turns out that copying using copy does work. I'm not sure
what I was doing wrong before, but now I'm getting what I wanted.

Regards,
Jon

···

On Fri, Oct 16, 2015 at 10:37 AM, Benjamin Root <ben.v.root at gmail.com> wrote:

Traitlets might be the solution here. You set up your proxy artist to have
properties that are linked to the properties of the plot object. When one
is updated, the other gets updated as well. The automatic linking of plot
objects to legend proxy artists is is one of the many benefits that would
come about with the future inclusion of traitlets in matplotlib. However, I
don't think you need to wait for us to get that aspect working. Since you
are already creating proxy artists, I think it shouldn't be that much more
effort to link their properties together with traitlets.

Unfortunately, the documentation is fairly sparse, and examples are
minimal as well. I know there was some decent examples during the SciPy
tutorials, but I can't seem to find it at the moment...

Ben Root

On Fri, Oct 16, 2015 at 10:10 AM, Slavin, Jonathan < > jslavin at cfa.harvard.edu> wrote:

Hi,

I have a plot on which I want to plot many points as open circles. I
also want to include a legend. The problem is that while a thin marker
edge width works very nicely for the plot, it is difficult to see in the
legend. My solution, which does work, is to define Line2D objects as proxy
artists and keep all the attributes the same except the mew, which I
increase. However, this seems error prone: if one changes attributes of
the line, then one has to also make those same changes to the proxy artist
line. I thought a better solution was to create the proxy artist as a
duplicate (copy) of the line and then change the mew via line.set_mew(n).
However, I haven't been able to figure out how to duplicate a Line2D
object. I tried copy and deepcopy from the python builtin copy module, but
those didn't work. Any help on this (including alternative ways of
approaching the problem) would be appreciated.

Thanks,
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
Matplotlib-users Info Page

--
________________________________________________________
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/20151016/8a84d1e4/attachment-0001.html&gt;