Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
MNT: expire legend-related deprecations#29832
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletionsdoc/api/next_api_changes/behavior/29832-REC.rst
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Mixing positional and keyword arguments for ``legend`` handles and labels... | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
... is no longer valid. If passing *handles* and *labels* to ``legend``, they must | ||
now be passed either both positionally or both as keywords. | ||
Legend labels for ``plot`` | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Previously if a sequence was passed to the *label* parameter of `~.Axes.plot` when | ||
plotting a single dataset, the sequence was automatically cast to string for the legend | ||
label. Now, if the sequence length is not one an error is raised. To keep the old | ||
behavior, cast the sequence to string before passing. |
7 changes: 0 additions & 7 deletionslib/matplotlib/axes/_base.py
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
8 changes: 3 additions & 5 deletionslib/matplotlib/legend.py
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
32 changes: 10 additions & 22 deletionslib/matplotlib/tests/test_legend.py
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 |
---|---|---|
@@ -390,17 +390,14 @@ def test_legend_kwargs_handles_labels(self): | ||
ax.legend(labels=('a', 'b'), handles=(lnc, lns)) | ||
Legend.assert_called_with(ax, (lnc, lns), ('a', 'b')) | ||
deftest_error_mixed_args_and_kwargs(self): | ||
fig, ax = plt.subplots() | ||
th = np.linspace(0, 2*np.pi, 1024) | ||
lns, = ax.plot(th, np.sin(th), label='sin') | ||
lnc, = ax.plot(th, np.cos(th), label='cos') | ||
msg = 'must both be passed positionally or both as keywords' | ||
with pytest.raises(TypeError, match=msg): | ||
ax.legend((lnc, lns), labels=('a', 'b')) | ||
def test_parasite(self): | ||
from mpl_toolkits.axes_grid1 import host_subplot # type: ignore[import] | ||
@@ -460,16 +457,13 @@ def test_legend_kw_args(self): | ||
fig, (lines, lines2), ('a', 'b'), loc='right', | ||
bbox_transform=fig.transFigure) | ||
deftest_error_args_kwargs(self): | ||
fig, axs = plt.subplots(1, 2) | ||
lines = axs[0].plot(range(10)) | ||
lines2 = axs[1].plot(np.arange(10) * 2.) | ||
msg = 'must both be passed positionally or both as keywords' | ||
with pytest.raises(TypeError, match=msg): | ||
fig.legend((lines, lines2), labels=('a', 'b')) | ||
def test_figure_legend_outside(): | ||
@@ -1178,21 +1172,15 @@ def test_plot_multiple_input_single_label(label): | ||
assert legend_texts == [str(label)] * 2 | ||
def test_plot_single_input_multiple_label(): | ||
# test ax.plot() with 1D array like input | ||
# and iterable label | ||
x = [1, 2, 3] | ||
y = [2, 5, 6] | ||
fig, ax = plt.subplots() | ||
rcomer marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
with pytest.raises(ValueError, | ||
match='label must be scalar or have the same length'): | ||
ax.plot(x, y, label=['low', 'high']) | ||
def test_plot_single_input_list_label(): | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.