How to set markers size in Scatter plot in Matplotlib?

To set the size of the markers, you have to pass sizes to the keyword argument s of the scatter() function.

matplotlib.pyplot.scatter(x, y, s=None, c=None)

It is seen that the diameter of the data point in the scatter plot is proportional to the numerical value it represents. That is why it is recommended that you provide the size of each marker.

Note: When you specify the size of each marker, then pass a list whose length is equal to the number of data points.

However if you want the size of all markers to be same, then pass a floating-point value to the keyword parameter s.

In the following example, we will draw a scatter plot having 10 data points. Here, we will specify the size of each data point.

import matplotlib.pyplot as plt

#Data Points
x = [1, 1, 3, 2, 2, 3, 4, 5, 4, 7]
y = [4, 3, 2, 4, 7, 4, 1, 10, 3, 2]
#Markers Size
markersSize = [162, 66, 161, 34, 60, 217, 132, 205, 207, 120]
#Draw Scatter Plot
plt.scatter(x, y, s=markersSize)
#Show Scatter Plot
plt.show()

Output

Matplotlib markers size scatter plot

If you don't want to specify the size of each data point, just pass a floating-point value. When you do this, all the data points will have the same size.

import matplotlib.pyplot as plt

#Data Points
x = [1, 1, 3, 2, 2, 3, 4, 5, 4, 7]
y = [4, 3, 2, 4, 7, 4, 1, 10, 3, 2]
#Draw Scatter Plot
plt.scatter(x, y, s=100)
#Show Scatter Plot
plt.show()

Output

Matplotlib same size markers scatter plot