8000 Merge "Scatter Symbol" and "Scatter Custom Symbol" examples by timhoffm · Pull Request #22276 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
8000

Merge "Scatter Symbol" and "Scatter Custom Symbol" examples #22276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions examples/lines_bars_and_markers/scatter_custom_symbol.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
"""
=====================
Scatter Custom Symbol
=====================

Creating a custom ellipse symbol in scatter plot.
=================================
Scatter plots with custom symbols
=================================

.. redirect-from:: /gallery/lines_bars_and_markers/scatter_symbol
.. redirect-from:: /gallery/lines_bars_and_markers/scatter_piecharts
"""

##############################################################################
# Using TeX symbols
# -----------------
# An easy way to customize scatter symbols is passing a TeX symbol name
# enclosed in $-signs as a marker. Below we use ``marker=r'$\clubsuit$'``.

import matplotlib.pyplot as plt
import numpy as np


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


x = np.arange(0.0, 50.0, 2.0)
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0
sizes = np.random.rand(*x.shape) * 800 + 500

fig, ax = plt.subplots()
ax.scatter(x, y, sizes, c="green", alpha=0.5, marker=r'$\clubsuit$',
label="Luck")
ax.set_xlabel("Leprechauns")
ax.set_ylabel("Gold")
ax.legend()
plt.show()

##############################################################################
# Using a custom path
# -------------------
# Alternatively, one can also pass a custom path of N vertices as a Nx2 array
# of x, y values as *marker*.

# unit area ellipse
rx, ry = 3., 1.
area = rx * ry * np.pi
Expand Down
52 changes: 0 additions & 52 deletions examples/lines_bars_and_markers/scatter_piecharts.py

This file was deleted.

25 changes: 0 additions & 25 deletions examples/lines_bars_and_markers/scatter_symbol.py

This file was deleted.

0