8000 Merge pull request #16102 from timhoffm/doc-marker-example · matplotlib/matplotlib@f38dfa1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f38dfa1

Browse files
authored
Merge pull request #16102 from timhoffm/doc-marker-example
Rework example "Scatter Star Poly" to "Marker examples"
2 parents 60cb031 + 371f0be commit f38dfa1

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

examples/lines_bars_and_markers/marker_reference.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
:doc:`/gallery/shapes_and_collections/marker_path`.
1414
1515
For a list of all markers see also the `matplotlib.markers` documentation.
16+
17+
For example usages see
18+
:doc:`/gallery/lines_bars_and_markers/scatter_star_poly`.
1619
"""
1720

1821
import matplotlib.pyplot as plt
Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
"""
2-
=================
3-
Scatter Star Poly
4-
=================
2+
===============
3+
Marker examples
4+
===============
55
6-
Create multiple scatter plots with different
7-
star symbols.
6+
Example with different ways to specify markers.
87
8+
For a list of all markers see also the `matplotlib.markers` documentation.
99
"""
1010
import numpy as np
1111
import matplotlib.pyplot as plt
1212

1313
# Fixing random state for reproducibility
1414
np.random.seed(19680801)
1515

16-
1716
x = np.random.rand(10)
1817
y = np.random.rand(10)
1918
z = np.sqrt(x**2 + y**2)
2019

21-
plt.subplot(321)
22-
plt.scatter(x, y, s=80, c=z, marker=">")
20+
fig, axs = plt.subplots(2, 3, sharex=True, sharey=True)
21+
22+
# marker symbol
23+
axs[0, 0].scatter(x, y, s=80, c=z, marker=">")
24+
axs[0, 0].set_title("marker='>'")
2325

24-
plt.subplot(322)
25-
plt.scatter(x, y, s=80, c=z, marker=(5, 0))
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\$'")
2629

30+
# marker from path
2731
verts = np.array([[-1, -1], [1, -1], [1, 1], [-1, -1]])
28-
plt.subplot(323)
29-
plt.scatter(x, y, s=80, c=z, marker=verts)
32+
axs[0, 2].scatter(x, y, s=80, c=z, marker=verts)
33+
axs[0, 2].set_title("marker=verts")
3034

31-
plt.subplot(324)
32-
plt.scatter(x, y, s=80, c=z, marker=(5, 1))
35+
# regular polygon marker
36+
axs[1, 0].scatter(x, y, s=80, c=z, marker=(5, 0))
37+
axs[1, 0].set_title("marker=(5, 0)")
3338

34-
plt.subplot(325)
35-
plt.scatter(x, y, s=80, c=z, marker='+')
39+
# regular star marker
40+
axs[1, 1].scatter(x, y, s=80, c=z, marker=(5, 1))
41+
axs[1, 1].set_title("marker=(5, 1)")
3642

37-
plt.subplot(326)
38-
plt.scatter(x, y, s=80, c=z, marker=(5, 2))
43+
# regular asterisk marker
44+
axs[1, 2].scatter(x, y, s=80, c=z, marker=(5, 2))
45+
axs[1, 2].set_title("marker=(5, 2)")
3946

47+
plt.tight_layout()
4048
plt.show()

lib/matplotlib/markers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
8585
* :doc:`/gallery/lines_bars_and_markers/marker_reference`
8686
* :doc:`/gallery/shapes_and_collections/marker_path`
87+
* :doc:`/gallery/lines_bars_and_markers/scatter_star_poly`
8788
8889
8990
.. |m00| image:: /_static/markers/m00.png

0 commit comments

Comments
 (0)
0