[ Web Proxy ]
URL:
Viewing: https://matplotlib.org/stable/api/_as_gen/../../devel/MEP/../../plot_types/basic/scatter_plot.html [Back]  [Original]

scatter(x, y) — Matplotlib 3.11.2 documentation
Back to top
Search the docs ...:

scatter(x, y)#

A scatter plot of y versus x with varying marker size and/or color.

See scatter.

scatter plot [scatter plot]
import matplotlib.pyplot as plt
import numpy as np

plt.style.use('_mpl-gallery')

# make the data
np.random.seed(3)
x = 4 + np.random.normal(0, 2, 24)
y = 4 + np.random.normal(0, 2, len(x))
# size and color:
sizes = np.random.uniform(15, 80, len(x))
colors = np.random.uniform(15, 80, len(x))

# plot
fig, ax = plt.subplots()

ax.scatter(x, y, s=sizes, c=colors, vmin=0, vmax=100)

ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
       ylim=(0, 8), yticks=np.arange(1, 8))

plt.show()

Gallery generated by Sphinx-Gallery


Web Proxy Viewer  |  New URL  |  Original Page