Version 3.0.2
matplotlib

Table of Contents

Related Topics

Scatter plot

This example showcases a simple scatter plot.

============
Scatter plot
============

This example showcases a simple scatter plot.
"""
import numpy as np
import matplotlib.pyplot as plt

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


N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = (30 * np.random.rand(N))**2  # 0 to 15 point radii

plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
Traceback (most recent call last):
  File "/build/matplotlib-xz4j8t/matplotlib-3.1.2/examples/shapes_and_collections/scatter.py", line 1
    ============
    ^
SyntaxError: invalid syntax

References

The use of the following functions and methods is shown in this example:

import matplotlib

matplotlib.axes.Axes.scatter
matplotlib.pyplot.scatter

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery