rootpy matplotlib

48 views
Skip to first unread message

Peter Waller

unread,
Jun 19, 2013, 9:37:39 AM6/19/13
to rootpy...@googlegroups.com, James Robinson
Hi James,

I'm a little busy right now and I don't have experience which can immediately help you answer this. I've forwarded your question on to rootpy-users. I hope someone else can respond.

Best of luck,

- Peter

---------- Forwarded message ----------
From: James Robinson <james.r...@cern.ch>
Date: 19 June 2013 14:34
Subject: rootpy
To: Pete Waller <p...@pwaller.net>

[snip]

I've just switched to using rootpy for plotting and I have a
matplotlib question. If I plot a histogram with rplt.hist in a 'line'
style rather than a 'filled' style, can I get the legend to display a
line rather than a box? I know I can do this if I write my own wrapper
around this that adds a proxy-artist, but it looks like rplt is
already giving me a matplotlib.patches.Polygon object - is there a
nice way to get the legend to draw this in the same way as a Line2D.

[snip]

Noel Dawe

unread,
Jun 20, 2013, 3:31:27 AM6/20/13
to rootpy...@googlegroups.com, James Robinson
Hi James,

Thanks for pointing this out. root2matplotlib.hist() now creates the appropriate proxy artist for the legend based on the legendstyle attribute of each histogram:


If legendstyle = 'F' then a Rectangle proxy artist is used, otherwise a Line2D is used.

Also hist() now uses fill_between() and step() to separately fill the patch (if filled) and draw the upper edge to prevent the lower line of a histogram patch (along the x-axis) from being drawn:


Cheers,
Noel

--
You received this message because you are subscribed to the Google Groups "rootpy users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rootpy-users...@googlegroups.com.
To post to this group, send email to rootpy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rootpy-users/CACmmWH0C5_qKa3VCct7qntkoFvcqExqjXWcBEVELsCtZ6qFqXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Noel Dawe

unread,
Jun 20, 2013, 3:38:55 AM6/20/13
to rootpy...@googlegroups.com, James Robinson
I also noticed that matplotlib places lines above patches by default in the legend so if you want a specific order in your legend (maybe to match the order in a stack for example) you may need to specify the order manually:


Noel

Noel Dawe

unread,
Jun 20, 2013, 4:10:11 AM6/20/13
to James Robinson, rootpy...@googlegroups.com, Pete Waller
Hi James,

You will need to register in the rootpy-users google group to post:


Noel

On Thu, Jun 20, 2013 at 1:01 AM, James Robinson <james.em...@gmail.com> wrote:
Hi Noel,

Thanks for the quick response! As I said in a earlier email (which seems to have bounced from the rootpy-users group) I implemented this in a horrible hack-y proxy artist way. I'll look into switching to this later today. The ordering thing is annoying, but I have a function that reorders the labels and handles for the legend so this is OK.

Thanks again,
James
Reply all
Reply to author
Forward
0 new messages