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

Skip to content

Commit 8dcc2e2

Browse files
committed
Improve plot() docstring.
- Mark `x`, `y`, `fmt` as positional-only. - Scalar values are not broadcasted against non-scalar values, despite what the docstring claims.
1 parent 4dbbd22 commit 8dcc2e2

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,8 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs):
13811381
13821382
Call signatures::
13831383
1384-
plot([x], y, [fmt], data=None, **kwargs)
1385-
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)
1384+
plot([x], y, [fmt], /, *, data=None, **kwargs)
1385+
plot([x], y, [fmt], [x2], y2, [fmt2], ..., /, **kwargs)
13861386
13871387
The coordinates of the points or line nodes are given by *x*, *y*.
13881388
@@ -1405,6 +1405,7 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs):
14051405
14061406
When conflicting with *fmt*, keyword arguments take precedence.
14071407
1408+
14081409
**Plotting labelled data**
14091410
14101411
There's a convenient way for plotting objects with labelled data (i.e.
@@ -1452,19 +1453,20 @@ def plot(self, *args, scalex=True, scaley=True, **kwargs):
14521453
Alternatively, you can also change the style cycle using the
14531454
'axes.prop_cycle' rcParam.
14541455
1456+
14551457
Parameters
14561458
----------
14571459
x, y : array-like or scalar
14581460
The horizontal / vertical coordinates of the data points.
1459-
*x* values are optional. If not given, they default to
1460-
``[0, ..., N-1]``.
1461+
*x* values are optional and default to `range(len(y))`.
1462+
1463+
Commonly, these parameters are 1D arrays.
14611464
1462-
Commonly, these parameters are arrays of length N. However,
1463-
scalars are supported as well (equivalent to an array with
1464-
constant value).
1465+
They can also be scalars, or two-dimensional (in that case, the
1466+
columns represent separate data sets).
14651467
1466-
The parameters can also be 2-dimensional. Then, the columns
1467-
represent separate data sets.
1468+
These arguments cannot be passed as keywords (as indicated by the
1469+
``/`` in the function signature).
14681470
14691471
fmt : str, optional
14701472
A format string, e.g. 'ro' for red circles. See the *Notes*

0 commit comments

Comments
 (0)