|
5 | 5 |
|
6 | 6 | Example with different ways to specify markers.
|
7 | 7 |
|
8 |
| -For a list of all markers see also the `matplotlib.markers` documentation. |
| 8 | +See also the `matplotlib.markers` documentation for a list of all markers and |
| 9 | +:doc:`/gallery/lines_bars_and_markers/marker_reference` for more information |
| 10 | +on configuring markers. |
| 11 | +
|
| 12 | +.. redirect-from:: /gallery/lines_bars_and_markers/scatter_custom_symbol |
| 13 | +.. redirect-from:: /gallery/lines_bars_and_markers/scatter_symbol |
| 14 | +.. redirect-from:: /gallery/lines_bars_and_markers/scatter_piecharts |
9 | 15 | """
|
10 | 16 | import matplotlib.pyplot as plt
|
11 | 17 | import numpy as np
|
|
17 | 23 | y = np.random.rand(10)
|
18 | 24 | z = np.sqrt(x**2 + y**2)
|
19 | 25 |
|
20 |
| -fig, axs = plt.subplots(2, 3, sharex=True, sharey=True) |
| 26 | +fig, axs = plt.subplots(2, 3, sharex=True, sharey=True, layout="constrained") |
21 | 27 |
|
22 |
| -# marker symbol |
| 28 | +# Matplotlib marker symbol |
23 | 29 | axs[0, 0].scatter(x, y, s=80, c=z, marker=">")
|
24 | 30 | axs[0, 0].set_title("marker='>'")
|
25 | 31 |
|
26 |
| -# marker from TeX |
27 |
| -axs[0, 1].scatter(x, y, s=80, c=z, marker=r'$\alpha$') |
28 |
| -axs[0, 1].set_title(r"marker=r'\$\alpha\$'") |
| 32 | +# marker from TeX: passing a TeX symbol name enclosed in $-signs |
| 33 | +axs[0, 1].scatter(x, y, s=80, c=z, marker=r"$\clubsuit$") |
| 34 | +axs[0, 1].set_title(r"marker=r'\$\clubsuit\$'") |
29 | 35 |
|
30 |
| -# marker from path |
| 36 | +# marker from path: passing a custom path of N vertices as a (N, 2) array-like |
31 | 37 | verts = [[-1, -1], [1, -1], [1, 1], [-1, -1]]
|
32 | 38 | axs[0, 2].scatter(x, y, s=80, c=z, marker=verts)
|
33 | 39 | axs[0, 2].set_title("marker=verts")
|
34 | 40 |
|
35 |
| -# regular polygon marker |
| 41 | +# regular pentagon marker |
36 | 42 | axs[1, 0].scatter(x, y, s=80, c=z, marker=(5, 0))
|
37 | 43 | axs[1, 0].set_title("marker=(5, 0)")
|
38 | 44 |
|
39 |
| -# regular star marker |
| 45 | +# regular 5-pointed star marker |
40 | 46 | axs[1, 1].scatter(x, y, s=80, c=z, marker=(5, 1))
|
41 | 47 | axs[1, 1].set_title("marker=(5, 1)")
|
42 | 48 |
|
43 |
| -# regular asterisk marker |
| 49 | +# regular 5-pointed asterisk marker |
44 | 50 | axs[1, 2].scatter(x, y, s=80, c=z, marker=(5, 2))
|
45 | 51 | axs[1, 2].set_title("marker=(5, 2)")
|
46 | 52 |
|
47 |
| -plt.tight_layout() |
48 | 53 | plt.show()
|
0 commit comments