Skip to content

Commit b0e0054

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 8d62769 commit b0e0054

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/matplotlib/axes/_axes.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs):
13351335
13361336
Call signatures::
13371337
1338-
plot([x], y, [fmt], data=None, **kwargs)
1338+
plot([x], y, [fmt], *, data=None, **kwargs)
13391339
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)
13401340
13411341
The coordinates of the points or line nodes are given by *x*, *y*.
@@ -1359,6 +1359,7 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs):
13591359
13601360
When conflicting with *fmt*, keyword arguments take precedence.
13611361
1362+
13621363
**Plotting labelled data**
13631364
13641365
There's a convenient way for plotting objects with labelled data (i.e.
@@ -1406,19 +1407,19 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs):
14061407
Alternatively, you can also change the style cycle using the
14071408
'axes.prop_cycle' rcParam.
14081409
1410+
14091411
Parameters
14101412
----------
14111413
x, y : array-like or scalar
14121414
The horizontal / vertical coordinates of the data points.
1413-
*x* values are optional. If not given, they default to
1414-
``[0, ..., N-1]``.
1415+
*x* values are optional and default to `range(len(y))`.
14151416
1416-
Commonly, these parameters are arrays of length N. However,
1417-
scalars are supported as well (equivalent to an array with
1418-
constant value).
1417+
Commonly, these parameters are 1D arrays.
14191418
1420-
The parameters can also be 2-dimensional. Then, the columns
1421-
represent separate data sets.
1419+
They can also be scalars, or two-dimensional (in that case, the
1420+
columns represent separate data sets).
1421+
1422+
These arguments cannot be passed as keywords.
14221423
14231424
fmt : str, optional
14241425
A format string, e.g. 'ro' for red circles. See the *Notes*
@@ -1428,6 +1429,8 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs):
14281429
basic line properties. All of these and more can also be
14291430
controlled by keyword arguments.
14301431
1432+
This argument cannot be passed as keyword.
1433+
14311434
data : indexable object, optional
14321435
An object with labelled data. If given, provide the label names to
14331436
plot in *x* and *y*.

0 commit comments

Comments
 (0)