|
1 | 1 | """ |
2 | | -=========== |
3 | | -Simple plot |
4 | | -=========== |
| 2 | +========== |
| 3 | +Basic plot |
| 4 | +========== |
5 | 5 |
|
6 | | -A simple plot where a list of numbers are plotted against their index, |
7 | | -resulting in a straight line. Use a format string (here, 'o-r') to set the |
8 | | -markers (circles), linestyle (solid line) and color (red). |
| 6 | +A basic plot using the :ref:`pyplot_interface`. |
| 7 | +
|
| 8 | +- `~.pyplot.plot` plots the data y versus x as lines and/or markers. |
| 9 | +- `~.pyplot.title`, `~.pyplot.xlabel` and `~.pyplot.ylabel` set the title, |
| 10 | + x-axis label and y-axis label. |
| 11 | +- `~.pyplot.show` displays the plot. |
9 | 12 |
|
10 | 13 | .. redirect-from:: /gallery/pyplots/fig_axes_labels_simple |
11 | 14 | .. redirect-from:: /gallery/pyplots/pyplot_formatstr |
| 15 | +.. redirect-from:: /gallery/pyplots/pyplot_text |
12 | 16 | """ |
13 | 17 |
|
14 | 18 | import matplotlib.pyplot as plt |
| 19 | +import numpy as np |
| 20 | + |
| 21 | +x = np.arange(0.0, 2.0, 0.01) |
| 22 | +y = np.sin(2 * np.pi * x) |
15 | 23 |
|
16 | | -plt.plot([1, 2, 3, 4], 'o-r') |
17 | | -plt.ylabel('some numbers') |
| 24 | +plt.plot(x, y) |
| 25 | +plt.title("A basic plot using pyplot") |
| 26 | +plt.xlabel('Time [s]') |
| 27 | +plt.ylabel('Voltage [mV]') |
18 | 28 | plt.show() |
19 | 29 |
|
20 | 30 | # %% |
|
25 | 35 | # in this example: |
26 | 36 | # |
27 | 37 | # - `matplotlib.pyplot.plot` |
| 38 | +# - `matplotlib.pyplot.title` |
| 39 | +# - `matplotlib.pyplot.ylabel` |
28 | 40 | # - `matplotlib.pyplot.ylabel` |
29 | 41 | # - `matplotlib.pyplot.show` |
0 commit comments