Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate column cycling when plot() inputs have nonmatching shapes. #9826

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
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/api/api_changes/2017-11-24-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deprecations
````````````

When given 2D inputs with non-matching numbers of columns, `~.pyplot.plot`
currently cycles through the columns of the narrower input, until all the
columns of the wider input have been plotted. This behavior is deprecated; in
the future, only broadcasting (1 column to *n* columns) will be performed.
3 changes: 3 additions & 0 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ def _plot_args(self, tup, kwargs):
func = self._makefill

ncx, ncy = x.shape[1], y.shape[1]
if ncx > 1 and ncy > 1 and ncx != ncy:
cbook.warn_deprecated("2.2", "cycling among columns of inputs "
"with non-matching shapes is deprecated.")
for j in xrange(max(ncx, ncy)):
seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
ret.append(seg)
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import matplotlib.patches as mpatches
import matplotlib.colors as mcolors
from numpy.testing import assert_allclose, assert_array_equal
from matplotlib.cbook import IgnoredKeywordWarning
from matplotlib.cbook import (
IgnoredKeywordWarning, MatplotlibDeprecationWarning)
from matplotlib.cbook._backports import broadcast_to

# Note: Some test cases are run twice: once normally and once with labeled data
Expand Down Expand Up @@ -5498,3 +5499,8 @@ def test_empty_errorbar_legend():
ax.errorbar([], [], xerr=[], label='empty y')
ax.errorbar([], [], yerr=[], label='empty x')
ax.legend()


def test_plot_columns_cycle_deprecation():
with pytest.warns(MatplotlibDeprecationWarning):
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))