-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix collection legend handlers #7832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
QuLogic
merged 3 commits into
matplotlib:v2.x
from
tacaswell:fix_collection_legend_handlers
Jan 15, 2017
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,10 @@ | |
import numpy as np | ||
|
||
from matplotlib.testing.decorators import image_comparison, cleanup | ||
from matplotlib.cbook import MatplotlibDeprecationWarning | ||
import matplotlib.pyplot as plt | ||
import matplotlib as mpl | ||
import matplotlib.patches as mpatches | ||
import matplotlib.transforms as mtrans | ||
import matplotlib.collections as mcollections | ||
|
||
|
||
@image_comparison(baseline_images=['legend_auto1'], remove_text=True) | ||
|
@@ -110,7 +109,8 @@ def test_fancy(): | |
plt.subplot(121) | ||
plt.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='XX\nXX') | ||
plt.plot([5] * 10, 'o--', label='XX') | ||
plt.errorbar(list(xrange(10)), list(xrange(10)), xerr=0.5, yerr=0.5, label='XX') | ||
plt.errorbar(list(xrange(10)), list(xrange(10)), xerr=0.5, | ||
yerr=0.5, label='XX') | ||
plt.legend(loc="center left", bbox_to_anchor=[1.0, 0.5], | ||
ncol=2, shadow=True, title="My legend", numpoints=1) | ||
|
||
|
@@ -123,7 +123,8 @@ def test_framealpha(): | |
plt.legend(framealpha=0.5) | ||
|
||
|
||
@image_comparison(baseline_images=['scatter_rc3', 'scatter_rc1'], remove_text=True) | ||
@image_comparison(baseline_images=['scatter_rc3', 'scatter_rc1'], | ||
remove_text=True) | ||
def test_rc(): | ||
# using subplot triggers some offsetbox functionality untested elsewhere | ||
fig = plt.figure() | ||
|
@@ -221,8 +222,8 @@ def test_warn_args_kwargs(self): | |
ax.legend((lnc, lns), labels=('a', 'b')) | ||
|
||
warn.assert_called_with("You have mixed positional and keyword " | ||
"arguments, some input will be " | ||
"discarded.") | ||
"arguments, some input will be " | ||
"discarded.") | ||
|
||
|
||
@image_comparison(baseline_images=['legend_stackplot'], extensions=['png']) | ||
|
@@ -273,10 +274,10 @@ def test_nanscatter(): | |
|
||
@image_comparison(baseline_images=['not_covering_scatter'], extensions=['png']) | ||
def test_not_covering_scatter(): | ||
colors = ['b','g','r'] | ||
colors = ['b', 'g', 'r'] | ||
|
||
for n in range(3): | ||
plt.scatter([n,], [n,], color=colors[n]) | ||
plt.scatter([n], [n], color=colors[n]) | ||
|
||
plt.legend(['foo', 'foo', 'foo'], loc='best') | ||
plt.gca().set_xlim(-0.5, 2.2) | ||
|
@@ -296,7 +297,28 @@ def test_not_covering_scatter_transform(): | |
plt.legend(['foo', 'bar'], loc='best') | ||
|
||
|
||
@cleanup | ||
def test_linecollection_scaled_dashes(): | ||
lines1 = [[(0, .5), (.5, 1)], [(.3, .6), (.2, .2)]] | ||
lines2 = [[[0.7, .2], [.8, .4]], [[.5, .7], [.6, .1]]] | ||
lines3 = [[[0.6, .2], [.8, .4]], [[.5, .7], [.1, .1]]] | ||
lc1 = mcollections.LineCollection(lines1, linestyles="--", lw=3) | ||
lc2 = mcollections.LineCollection(lines2, linestyles="-.") | ||
lc3 = mcollections.LineCollection(lines3, linestyles=":", lw=.5) | ||
|
||
fig, ax = plt.subplots() | ||
ax.add_collection(lc1) | ||
ax.add_collection(lc2) | ||
ax.add_collection(lc3) | ||
|
||
leg = ax.legend([lc1, lc2, lc3], ["line1", "line2", 'line 3']) | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is going in 2.0, it probably should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assert oh.get_linestyles()[0][0] == lh._dashOffset | ||
|
||
|
||
if __name__ == '__main__': | ||
import nose | ||
nose.runmodule(argv=['-s', '--with-doctest'], exit=False) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).