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

Skip to content

Commit 503af4b

Browse files
committed
Deprecate column cycling when plot() inputs have nonmatching shapes.
Currently, something like plot([[0, 1, 2], [3, 4, 5]], [[0, 1], [2, 3]]) will plot column 0 of x vs column 0 of y; column 1 of x vs column 1 of y; and column 2 of x vs column 1 of y (i.e. cycle among columns). This behavior appears to be error-prone to say the least. Note that "normal" broadcasting (1->n) is not deprecated.
1 parent 813d842 commit 503af4b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

doc/api/api_changes/2017-11-24-AL.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecations
2+
````````````
3+
4+
When given 2D inputs with non-matching numbers of columns, `~.pyplot.plot`
5+
currently cycles through the columns of the narrower input, until all the
6+
columns of the wider input have been plotted. This behavior is deprecated; in
7+
the future, only broadcasting (1 column to *n* columns) will be performed.

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ def _plot_args(self, tup, kwargs):
391391
func = self._makefill
392392

393393
ncx, ncy = x.shape[1], y.shape[1]
394+
if ncx > 1 and ncy > 1 and ncx != ncy:
395+
cbook.warn_deprecated("2.2", "cycling among columns of inputs "
396+
"with non-matching shapes is deprecated.")
394397
for j in xrange(max(ncx, ncy)):
395398
seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
396399
ret.append(seg)

0 commit comments

Comments
 (0)