Rewrite of the entire legend documentation, including tidy ups of code and style to all things "legend".#2442
Conversation
lib/matplotlib/testing/decorators.py
Outdated
There was a problem hiding this comment.
@mdboom - pinging you here. I did this so I could have methods which get cleaned up. I've got some ideas on how to tidy up the whole suite of testing decorators, but I was doing my best to restrain from doing them in this PR. 😉
There was a problem hiding this comment.
I think this code predated functools (Python 2.5), so I'm glad to modernize it.
lib/matplotlib/axes/_axes.py
Outdated
There was a problem hiding this comment.
There's a coma after line. Is that wanted (is that valid python syntax?)?
There was a problem hiding this comment.
That is to un-pack the length one list that plot returns so line is a Line2D object, not a list.
There was a problem hiding this comment.
On 2013/09/20 3:44 AM, Varoquaux wrote:
In lib/matplotlib/axes/_axes.py:
To automatically generate the legend from labels::line, = ax.plot([1, 2, 3], label='Inline label')Ah, nice. Thanks
It's a common idiom, and I use it, but with hesitation; it "looks wrong"
at first glance, as you noticed. The alternative, explicitly indexing
with [0] at the end, is less concise but more visually obvious.
Therefore it might be preferable in documentation intended for newcomers.
There was a problem hiding this comment.
I rather like the the idiom. I would suggest adding a note explaining it before changing it to [0].
|
I agree with this in concept -- I probably won't have a chance to review it properly until after tagging 1.3.1, however. |
There was a problem hiding this comment.
Spelling mistake? I think there's only one l in "originally".
There was a problem hiding this comment.
It is double "l" in English. I couldn't find whether there is an American spelling (http://www.merriam-webster.com/dictionary/originally)
|
This is nice work! The documentation is much better. Thanks! |
doc/users/legend_guide.rst
Outdated
|
I've been a little busy lately and not been able to bang the drum for this PR - sorry for letting it slip. I've rebased, and believe I've addressed the comments above. Lets extend the merge date to this Friday - the 1st of November. |
|
@mdboom - any ideas on what's up with the tests? As far as I'm aware, I've not done anything to upset mlab, but you can never be certain I suppose. |
|
Hmm... not sure. I've restarted the tests just for good measure... if still failing, I'll investigate further. |
|
I'm stumped by the test failures (and can't reproduce them here). Maybe we try reverting the change to |
|
This looks vaguely like the failures that are showing up on #2236 in the 3.x builds (in that there are errors that the tests don't exist). |
|
@pelson any progress on this? |
|
I've rebased - the failing test wasn't to do with this change as far as I can see. Hopefully the tests will work now. |
|
I've just rebased and I think this is good to go. Anyone willing to merge? |
doc/users/legend_guide.rst
Outdated
There was a problem hiding this comment.
There should be a sentence or clause here hedging that this will not work for all artists.
There was a problem hiding this comment.
a list of handles/artists which exist on the Axes which can be used to generate entries for the resulting legend.
There is no hedging needed. The function always works, it just doesn't always return all of the artists that have been added to the axes. I do go on to mention that not all artists can be drawn in a legend, and ideally would keep the two paragraphs separate.
Do you still want me to do this?
There was a problem hiding this comment.
I don't think it is clear that it will only return the artists which have registered handlers. I want to put a reference to that other paragraph here so people realize that they may need to keep reading.
There was a problem hiding this comment.
doc line related to comment about _ above.
|
Ok, I've added a commit on top of ceda68f - thanks for your thorough review @tacaswell. |
|
Note - this doesn't merge cleanly (whats new perhaps) - so rather than re-base and force you to have to re-read everything, I will merge this manually once I've got your 👍 @tacaswell. |
|
I left one minor comment, but other than that 👍 Should probably change the note in |
and style to all things "legend".
|
I decided to rebase @tacaswell - do you want to merge? |
Rewrite of the entire legend documentation, including tidy ups of code and style to all things "legend".
|
Woo-ho - thanks @tacaswell - hopefully I will stop being asked all the time how to do legends 😄! |
|
Unlikely. Legends have a lot of moving parts. |
First off - apologies for such a big PR.
This work represents several days effort in rationalising and extending the legend documentation throughout matplotlib. I've focused almost entirely on improving the documentation, but in the process I've also cleaned up the code and simplified some interfaces (in the interest of clearer documentation).
There are changes to some example files which may not seem relevant, but I've gone through the entire gallery to identify the necessary legend related plots, and as a result have removed some of the duplicates which shouldn't have been there in the first place.
Important:
I'd like to put an alternative perspective on the way we review this PR given how much effort this review will require. Instead of waiting for 👍s - I'd like to put a deadline of 14 days (4th October 2013) to have any 👎s, and provided any review actions are complete, either I, or some other kind soul, will merge this. I think this approach might work well for primarily documentation type changes and this is a good place to trial it out.
Thanks!