1# Import matplotlib
2import matplotlib.pyplot as plt
3
4# Set plot space as inline for inline plots and qt for external plots
5%matplotlib inline
6
7
8# Set the figure size in inches
9plt.figure(figsize=(10,6))
10
11plt.scatter(x, y, label = "label_name" )
12
13# Set x and y axes labels
14plt.xlabel('X Values')
15plt.ylabel('Y Values')
16
17plt.title('Scatter Title')
18plt.legend()
19plt.show()
1import numpy as npimport matplotlib.pyplot as plt
2# Create data
3N = 500x = np.random.rand(N)
4y = np.random.rand(N)
5colors = (0,0,0)
6area = np.pi*3
7# Plot
8plt.scatter(x, y, s=area, c=colors, alpha=0.5)
9plt.title('Scatter plot pythonspot.com')
10plt.xlabel('x')
11plt.ylabel('y')
12plt.show()
1import numpy as np
2np.random.seed(19680801)
3import matplotlib.pyplot as plt
4
5
6fig, ax = plt.subplots()
7for color in ['tab:blue', 'tab:orange', 'tab:green']:
8 n = 750
9 x, y = np.random.rand(2, n)
10 scale = 200.0 * np.random.rand(n)
11 ax.scatter(x, y, c=color, s=scale, label=color,
12 alpha=0.3, edgecolors='none')
13
14ax.legend()
15ax.grid(True)
16
17plt.show()