Debian Codegraph @

texmf-dist/doc/latex/elegantnote/image/scatter.py

raw
1 # This file is the source file of the scatter.pdf
2 # source page: https://matplotlib.org/gallery/shapes_and_collections/scatter.html
3 import numpy as np
4 import matplotlib.pyplot as plt
5
6 # Fixing random state for reproducibility
7 np.random.seed(19680801)
8
9
10 N = 50
11 x = np.random.rand(N)
12 y = np.random.rand(N)
13 colors = np.random.rand(N)
14 area = (30 * np.random.rand(N))**2 # 0 to 15 point radii
15
16 ax = plt.subplot(111)
17 ax.scatter(x, y, s=area, c=colors, alpha=0.5)
18
19 # Hide the right and top spines
20 ax.spines['right'].set_visible(False)
21 ax.spines['top'].set_visible(False)
22
23 # Only show ticks on the left and bottom spines
24 ax.yaxis.set_ticks_position('left')
25 ax.xaxis.set_ticks_position('bottom')
26
27 plt.savefig('scatter.pdf', transparent=True)