Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cbbebe2

Browse files
committed
Merge "Scatter Symbol" and "Scatter Custom Symbol" examples
Remove "Scatter plot with pie chart markers". This is only a variant of path-as-custom-symbol, which is already covered here. Also, all pie markers in the scatter plot have the same data distribution, so the pie is more a style thing and cannot convey additional datapoint-specific information. Also closes #22266 by using *sizes* instead of *s* and spelling out the color to make their meaning clearer.
1 parent 28e5798 commit cbbebe2

3 files changed

Lines changed: 31 additions & 83 deletions

File tree

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)