X Tutup
Skip to content

Fix collection legend handlers#7832

Merged
QuLogic merged 3 commits intomatplotlib:v2.xfrom
tacaswell:fix_collection_legend_handlers
Jan 15, 2017
Merged

Fix collection legend handlers#7832
QuLogic merged 3 commits intomatplotlib:v2.xfrom
tacaswell:fix_collection_legend_handlers

Conversation

@tacaswell
Copy link
Copy Markdown
Member

No description provided.

As part of scaling dashes with linewidth, unscaled versions of
the dash pattern are now tracked.  Make sure we copy these as well.
To prevent double-scaling of the pattern in the legend

Closes matplotlib#7814
@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jan 15, 2017
self._facecolors = other._facecolors
self._linewidths = other._linewidths
self._linestyles = other._linestyles
self._us_linestyles = other._us_linestyles
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anywhere that documents that 'us' means unscaled? It's rather an opaque prefix to me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, but I would prefer that be done in a seperate PR (created #7837 to track this).

import matplotlib.patches as mpatches
import matplotlib.transforms as mtrans

import matplotlib.collections as mc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not very consistent, but this is generally imported as mcoll or mcollections. Also, second blank line should be re-added.

h1, h2, h3 = leg.legendHandles

for oh, lh in zip((lc1, lc2, lc3), (h1, h2, h3)):
assert oh.get_linestyles()[0][1] == lh._dashSeq
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is going in 2.0, it probably should be assert_equal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert will work fine, though it is not as elegant.

h1, h2, h3 = leg.legendHandles

for oh, lh in zip((lc1, lc2, lc3), (h1, h2, h3)):
assert oh.get_linestyles()[0][1] == lh._dashSeq
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert will work fine, though it is not as elegant.

@NelleV NelleV changed the title Fix collection legend handlers [MRG+1] Fix collection legend handlers Jan 15, 2017
@NelleV
Copy link
Copy Markdown
Member

NelleV commented Jan 15, 2017

I have the same concerns as @QuLogic concerning the opaque prefix.

It looks good to me.

@tacaswell
Copy link
Copy Markdown
Member Author

Despite having written it I am un-willing to defend the _us prefix 😉

@tacaswell
Copy link
Copy Markdown
Member Author

going to leave the asserts to save the effort of converting them back to asserts in the near-to-mid future.

@QuLogic QuLogic changed the title [MRG+1] Fix collection legend handlers Fix collection legend handlers Jan 15, 2017
@QuLogic QuLogic merged commit f00274f into matplotlib:v2.x Jan 15, 2017
@tacaswell tacaswell deleted the fix_collection_legend_handlers branch January 16, 2017 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup