35 Scatterplot
35 Scatterplot
matplotlib.pyplot.scatter()
Scatter plots are used to observe relationship between variables and uses
dots to represent the relationship between them. The scatter() method in
the matplotlib library is used to draw a scatter plot. Scatter plots are
widely used to represent relation among variables and how change in one
affects the other.
Syntax
The syntax for scatter() method is given below:
x =[5, 7, 8, 7, 2, 17, 2, 9,
4, 11, 12, 9, 6]
plt.scatter(x, y, c ="blue")
Example 2: Scatter plot with different shape and colour for two datasets.
import matplotlib.pyplot as plt
# dataset-1
x1 = [89, 43, 36, 36, 95, 10,
66, 34, 38, 20]
# dataset2
x2 = [26, 29, 48, 64, 6, 5,
36, 66, 72, 40]
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
Example3 :
Other Parameters
dataindexable object, optional
If given, the following parameters also accept a string s,
which is interpreted as data[s] (unless this raises an
exception):
x, y, s, linewidths, edgecolors, c, facecolor, facecolors, color
**kwargsCollection properties