Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c3d8da

Browse filesBrowse files
authored
Merge pull request #18703 from timhoffm/doc-plot-array
Improve documentation of plot() with arrays
2 parents e12684d + f4874fa commit 6c3d8da
Copy full SHA for 6c3d8da

File tree

Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+10-7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.