8000 Merge pull request #22276 from timhoffm/doc-scatter-symbol · matplotlib/matplotlib@a2ddfc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a2ddfc0

Browse files
authored
Merge pull request #22276 from timhoffm/doc-scatter-symbol
Merge "Scatter Symbol" and "Scatter Custom Symbol" examples
2 parents 96af8c5 + cbbebe2 commit a2ddfc0

File tree

3 files changed

+31
-83
lines changed

3 files changed

+31
-83
lines changed

examples/lines_bars_and_markers/scatter_custom_symbol.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
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
7+
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_piecharts
88
"""
9+
10+
##############################################################################
11+
# Using TeX symbols
12+
# -----------------
13+
# An easy way to customize scatter symbols is passing a TeX symbol name
14+
# enclosed in $-signs as a marker. Below we use ``marker=r'$\clubsuit$'``.
15+
916
import matplotlib.pyplot as plt
1017
import numpy as np
1118

12-
1319
# Fixing random state for reproducibility
1420
np.random.seed(19680801)
1521

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

examples/lines_bars_and_markers/scatter_piecharts.py

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

examples/lines_bars_and_markers/scatter_symbol.py

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

0 commit comments

Comments
 (0)
0