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

Skip to content

Commit f4874fa

Browse files
committed
Improve documentation of plot() with arrays
1 parent 4b244a7 commit f4874fa

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,18 +1414,21 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs):
14141414
>>> plot(x1, y1, 'bo')
14151415
>>> plot(x2, y2, 'go')
14161416
1417-
- Alternatively, if your data is already a 2d array, you can pass it
1418-
directly to *x*, *y*. A separate data set will be drawn for every
1419-
column.
1417+
- If *x* and/or *y* are 2D arrays a separate data set will be drawn
1418+
for every column. If both *x* and *y* are 2D, they must have the
1419+
same shape. If only one of them is 2D with shape (N, m) the other
1420+
must have length N and will be used for every data set m.
14201421
1421-
Example: For an array ``a`` with shape (N, m) calling::
1422+
Example:
14221423
1423-
>>> plot(a)
1424+
>>> x = [1, 2, 3]
1425+
>>> y = np.array([[1, 2], [3, 4], [5, 6]])
1426+
>>> plot(x, y)
14241427
14251428
is equivalent to:
14261429
1427-
>>> for i in range(m):
1428-
... plot(a[:, i])
1430+
>>> for col in range(y.shape[1]):
1431+
... plot(x, y[:, col])
14291432
14301433
- The third way is to specify multiple sets of *[x]*, *y*, *[fmt]*
14311434
groups::

0 commit comments

Comments
 (0)