import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(10) #Generate an array of random numbers
y = np.random.rand(10)
plt.scatter(x, y) #Draw a scatterplot
plt.show()
The results are as follows.
■Difference between "scatter" and "plot"
A matplotlib function similar to scatter is "plot".
plot is a graph drawing function that can also draw scatterplots.
Change the above program as follows.
plt.scatter(x, y) #change as follows
↓↓↓
plt.plot(x, y, "o")
You should be able to draw a scatterplot similar to the one above. The advantage of scatter is that you can make more detailed settings than "plot".
For example:
"s":size
"c":color
"alpha":transmittance
"edgecolors":edge color
"marker":marker shape
plt.scatter(x, y, s=300, c="red", alpha=0.5,edgecolors="blue", marker="^")