# How to Set Marker Size of Scatter Plot in Matplotlib

The size of markers in the scatter plot is controlled by `s` keyword argument of the function `scatter()`, where `s` is a scalar or an array.

## `s` Keyword Argument of the Function `scatter()`

Syntax for `scatter` function:

``````matplotlib.pyplot.scatter(x, y,
s=None,
c='b',
marker='o',
cmap=None,
norm=None,
vmin=None,
vmax=None,
alpha=None,
linewidths=None,
faceted=True,
verts=None,
hold=None,
**kwargs)
``````

where, `s` is a scalar or an array of the same length as `x` and `y`, to set the `markersize`. The default marker size is `rcParams['lines.markersize'] ** 2`. According to documentation, `s` is the marker size in points**2.

### Set the Same Marker Size of All Points

``````import numpy as np
import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y=np.sin(x)

plt.scatter(x,y,s=500,c='magenta')

plt.title('Scatter plot of sinx')
plt.xlabel('x')
plt.ylabel('sinx')
plt.xlim(0,6)
plt.ylim(-2,2)
plt.show()
`````` ### Increase Markersize of Points Non-Uniformly

#### Double the Width of Markers

To double the `width` (or `height`) of the marker we need to increase `s` by a factor of `4` as `A = W*H => (2W)*(2H)= 4A`.

``````import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y = [a**2 for a in x]
s = [10*4**n for n in range(len(x))]
plt.scatter(x,y,s=s)
plt.title('Doubling width of marker in scatter plot')
plt.xlabel('x')
plt.ylabel('x**2')
plt.xlim(0,6)
plt.ylim(0,30)
plt.show()
`````` #### Double the Area of Markers

To double the area of the marker, we increase the `area` by a factor of `2` so the marker size scales linearly with the `area`.

``````import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y = [a**2 for a in x]
s = [10*2**n for n in range(len(x))]
plt.scatter(x,y,s=s)
plt.title('Doubling area of marker in scatter plot')
plt.xlabel('x')
plt.ylabel('x**2')
plt.xlim(0,6)
plt.ylim(0,30)
plt.show()
`````` ## `markersize` Parameter to Control Size in `plot` Method

``````import matplotlib.pyplot as plt

x = [1,2,3,4,5]
y = *len(x)

plt.plot(x,y, 'bo', markersize=10)
plt.show()
``````

Here the area of circle is controlled by `markersize` parameter. ## Related Article - Matplotlib Scatter

• How to Connect Scatterplot Points With Line in Matplotlib