Plot y versus x as lines and/or markers. Call signatures:: plot([x], y, [fmt], *, data=None, **kwargs) plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs) The coordinates of the points or line nodes are given by *x*, *y*. The optional par
(self, *args, scalex=True, scaley=True, data=None, **kwargs)
| 1546 | # _process_plot_var_args. |
| 1547 | @_docstring.interpd |
| 1548 | def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs): |
| 1549 | """ |
| 1550 | Plot y versus x as lines and/or markers. |
| 1551 | |
| 1552 | Call signatures:: |
| 1553 | |
| 1554 | plot([x], y, [fmt], *, data=None, **kwargs) |
| 1555 | plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs) |
| 1556 | |
| 1557 | The coordinates of the points or line nodes are given by *x*, *y*. |
| 1558 | |
| 1559 | The optional parameter *fmt* is a convenient way for defining basic |
| 1560 | formatting like color, marker and linestyle. It's a shortcut string |
| 1561 | notation described in the *Notes* section below. |
| 1562 | |
| 1563 | >>> plot(x, y) # plot x and y using default line style and color |
| 1564 | >>> plot(x, y, 'bo') # plot x and y using blue circle markers |
| 1565 | >>> plot(y) # plot y using x as index array 0..N-1 |
| 1566 | >>> plot(y, 'r+') # ditto, but with red plusses |
| 1567 | |
| 1568 | You can use `.Line2D` properties as keyword arguments for more |
| 1569 | control on the appearance. Line properties and *fmt* can be mixed. |
| 1570 | The following two calls yield identical results: |
| 1571 | |
| 1572 | >>> plot(x, y, 'go--', linewidth=2, markersize=12) |
| 1573 | >>> plot(x, y, color='green', marker='o', linestyle='dashed', |
| 1574 | ... linewidth=2, markersize=12) |
| 1575 | |
| 1576 | When conflicting with *fmt*, keyword arguments take precedence. |
| 1577 | |
| 1578 | |
| 1579 | **Plotting labelled data** |
| 1580 | |
| 1581 | There's a convenient way for plotting objects with labelled data (i.e. |
| 1582 | data that can be accessed by index ``obj['y']``). Instead of giving |
| 1583 | the data in *x* and *y*, you can provide the object in the *data* |
| 1584 | parameter and just give the labels for *x* and *y*:: |
| 1585 | |
| 1586 | >>> plot('xlabel', 'ylabel', data=obj) |
| 1587 | |
| 1588 | All indexable objects are supported. This could e.g. be a `dict`, a |
| 1589 | `pandas.DataFrame` or a structured numpy array. |
| 1590 | |
| 1591 | |
| 1592 | **Plotting multiple sets of data** |
| 1593 | |
| 1594 | There are various ways to plot multiple sets of data. |
| 1595 | |
| 1596 | - The most straight forward way is just to call `plot` multiple times. |
| 1597 | Example: |
| 1598 | |
| 1599 | >>> plot(x1, y1, 'bo') |
| 1600 | >>> plot(x2, y2, 'go') |
| 1601 | |
| 1602 | - If *x* and/or *y* are 2D arrays, a separate data set will be drawn |
| 1603 | for every column. If both *x* and *y* are 2D, they must have the |
| 1604 | same shape. If only one of them is 2D with shape (N, m) the other |
| 1605 | must have length N and will be used for every data set m. |