Fix collection legend handlers#7832
Conversation
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
| self._facecolors = other._facecolors | ||
| self._linewidths = other._linewidths | ||
| self._linestyles = other._linestyles | ||
| self._us_linestyles = other._us_linestyles |
There was a problem hiding this comment.
Is there anywhere that documents that 'us' means unscaled? It's rather an opaque prefix to me.
There was a problem hiding this comment.
no, but I would prefer that be done in a seperate PR (created #7837 to track this).
lib/matplotlib/tests/test_legend.py
Outdated
| import matplotlib.patches as mpatches | ||
| import matplotlib.transforms as mtrans | ||
|
|
||
| import matplotlib.collections as mc |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Since this is going in 2.0, it probably should be assert_equal.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
assert will work fine, though it is not as elegant.
|
I have the same concerns as @QuLogic concerning the opaque prefix. It looks good to me. |
|
Despite having written it I am un-willing to defend the |
|
going to leave the asserts to save the effort of converting them back to asserts in the near-to-mid future. |
No description provided.