8000 Merge "Scatter Symbol" and "Scatter Custom Symbol" examples · matplotlib/matplotlib@d345624 · GitHub
[go: up one dir, main page]

Skip to content

Commit d345624

Browse files
committed
Merge "Scatter Symbol" and "Scatter Custom Symbol" examples
Also closes #22266 by using *sizes* instead of *s* and spelling out the color to make their meaning clearer.
1 parent 28e5798 commit d345624

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

examples/lines_bars_and_markers/scatter_custom_symbol.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
"""
2-
=====================
3-
Scatter Custom Symbol
4-
=====================
5-
6-
Creating a custom ellipse symbol in scatter plot.
2+
=================================
3+
Scatter plots with custom symbols
4+
=================================
75
6+
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_symbol
87
"""
8+
9+
##############################################################################
10+
# Using TeX symbols
11+
# -----------------
12+
# An easy way to customize scatter symbols is passing a TeX symbol name
13+
# enclosed in $-signs as a marker. Below we use ``marker=r'$\clubsuit$'``.
14+
915
import matplotlib.pyplot as plt
1016
import numpy as np
1117

12-
1318
# Fixing random state for reproducibility
1419
np.random.seed(19680801)
1520

21+
22+
x = np.arange(0.0, 50.0, 2.0)
23+
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0
24+
sizes = np.random.rand(*x.shape) * 800 + 500
25+
26+
fig, ax = plt.subplots()
27+
ax.scatter(x, y, sizes, c="green", alpha=0.5, marker=r'$\clubsuit$',
28+
label="Luck")
29+
ax.set_xlabel("Leprechauns")
30+
ax.set_ylabel("Gold")
31+
ax.legend()
32+
plt.show()
33+
34+
##############################################################################
35+
# Using a custom path
36+
# -------------------
37+
# Alternatively, one can also pass a custom path of N vertices as a Nx2 array
38+
# of x, y values as *marker*.
39+
1640
# unit area ellipse
1741
rx, ry = 3., 1.
1842
area = rx * ry * np.pi

examples/lines_bars_and_markers/scatter_symbol.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0