Written and maintained by CASRAI Editorial Board
Last updated
In Matplotlib, markersize (short form ms) sets the size of the markers on a line drawn with plt.plot(). It is a float measured in points, and it is a linear size, so doubling it doubles the marker’s width and height. scatter() does not use it: that function has its own s argument, which is in points squared. Most “my marker size did nothing” problems come from mixing the two up.
Markersize versus s: which one sets the marker size
Two different arguments exist because plot() and scatter() build different objects. plot() returns Line2D objects whose properties include markersize or ms (a float); the Line2D documentation defines set_markersize(sz) as setting “the marker size in points”. scatter() takes s, documented as “the marker size in points**2 (typographic points are 1/72 in.)”, with a default of rcParams['lines.markersize'] ** 2.
| Function | Argument | Unit | Per-point sizes |
|---|---|---|---|
plt.plot() / ax.plot() |
markersize or ms |
points (linear, float) | One value per line |
plt.scatter() / ax.scatter() |
s |
points**2 (area) | Accepts an array of shape (n,) |
The practical consequence: to make a plot() marker twice as wide, double markersize; to make a scatter() marker twice as wide, multiply s by four. For the scatter() case in full, including grouping and seaborn, see Scatter Plot in Python: Matplotlib and Seaborn Step by Step.
What it is used for in research
Marker size controls legibility in figures: observed data points on a fitted curve, individual subjects on a line chart, or the points on a calibration plot all need to be visible at the final printed size without hiding each other. Marker size is also one of the choices that determines whether a figure survives reduction to a single journal column, a topic covered in Designing Effective Scientific Figures and in the journal-side rules on scientific figure requirements for submission.
Install or access
Matplotlib’s own installation page gives pip install matplotlib for pip and conda install -c conda-forge matplotlib for conda. Install it from there (see matplotlib.org installation guide), then import the plotting interface:
import matplotlib.pyplot as plt
Step by step: change the marker size in plt.plot
- Choose a marker. A line has no markers unless you ask for them: the
Line2Dconstructor default ismarker=None. Passmarker='o', or a format string such as'bo'(blue circles), which theplotdocumentation gives as its shortcut notation. - Pass the size. Add
markersize=(orms=) with a number in points. - Run and compare. Change the number and re-run until the markers read clearly at the size the figure will be printed.
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [2, 4, 3, 5]
fig, ax = plt.subplots()
ax.plot(x, y, marker='o', markersize=12) # keyword form
# ax.plot(x, y, 'go--', linewidth=2, markersize=12) # format string, as in the plot() docs example
plt.show()
The Matplotlib plot documentation contains the format-string form plot(x, y, 'go--', linewidth=2, markersize=12) and states that its keyword equivalent is plot(x, y, color='green', marker='o', linestyle='dashed', linewidth=2, markersize=12).
Change the size on an existing line (set_markersize)
plot() returns a list of Line2D objects. Keep the handle and call set_markersize(sz), where sz is a float in points; set_ms(sz) is an alias. get_markersize() returns the current size in points.
line, = ax.plot(x, y, marker='o')
line.set_markersize(10)
print(line.get_markersize()) # size in points
Related marker properties on the same line
The Line2D property list pairs each marker property with a short alias:
| Property | Short form | Type |
|---|---|---|
markersize |
ms |
float, in points |
markeredgewidth |
mew |
float, in points (get_markeredgewidth() returns points) |
markeredgecolor |
mec |
color |
markerfacecolor |
mfc |
color |
The Line2D constructor also accepts markerfacecoloralt and fillstyle for half-filled markers.
Change the default for every plot (rcParams)
The default comes from the lines.markersize setting. In the sample matplotlibrc in the Matplotlib customizing documentation it reads #lines.markersize: 6 # marker size, in points, next to #lines.markeredgewidth: 1.0 # the line width around the marker symbol. To change it for a script, set the runtime value before plotting:
import matplotlib as mpl
mpl.rcParams['lines.markersize'] = 8
Because scatter()‘s default is this value squared, changing lines.markersize also changes the default scatter size.
Output and how to read it
The size is physical: a marker of markersize=12 is 12 points across, where a typographic point is 1/72 inch (the unit definition given in the scatter documentation). Check the figure at the size it will be published. A marker edge is drawn with width markeredgewidth, so on very small markers a wide edge can dominate what you see.
Troubleshooting
No markers appear at all
The line was drawn with no marker set. Add marker='o' (or a format string such as 'o-'); markersize only changes markers that exist.
Changing markersize does nothing on a scatter plot
Use s with scatter() and remember it is points squared. See the table above.
I need a different size for each point
A single Line2D has one markersize. Use scatter() with s as an array, which the documentation specifies as shape (n,).
Small markers look like blobs
The scatter documentation notes that linewidth and edgecolor can visually interact with marker size and lead to artifacts when the marker is smaller than the linewidth. The same idea applies to plot() markers: if tiny markers look like blobs, try a smaller markeredgewidth (the sample matplotlibrc lists 1.0) and compare.
Alternatives that need no extra software
All of these ship with Matplotlib itself; each solves a different version of the problem.
| Goal | Use | Source |
|---|---|---|
| One size for a whole line | ax.plot(..., markersize=...) |
Line2D documentation |
| Resize a line after creating it | line.set_markersize(sz) or set_ms(sz) |
Line2D documentation |
| A different size for each point | ax.scatter(..., s=array) |
scatter documentation |
| A new default for the whole script | rcParams['lines.markersize'] |
Customizing Matplotlib documentation |
For labelling these markers in a legend, see Legend in Matplotlib, and for the seaborn line-plot equivalent see Seaborn Line Plots. Captions for the finished figure are covered under figure legend.
FAQ
What unit is markersize in Matplotlib?
Points. The Line2D documentation defines set_markersize as setting “the marker size in points”, and get_markersize() returns the size in points.
What is the difference between markersize and ms?
None. ms is the short alias; the Line2D property table lists them as markersize or ms.
What is the default marker size?
It comes from rcParams['lines.markersize']; the sample matplotlibrc in the Matplotlib documentation lists it as 6 points (shown commented out).
Why does s behave differently from markersize?
s is in points**2 while markersize is in points, so the two scale differently.
Sources
- Matplotlib documentation, matplotlib.lines.Line2D (checked 2026-10-29).
- Matplotlib documentation, matplotlib.pyplot.plot (checked 2026-10-29).
- Matplotlib documentation, matplotlib.pyplot.scatter (checked 2026-10-29).
- Matplotlib documentation, Customizing Matplotlib with style sheets and rcParams (checked 2026-10-29).
- Matplotlib documentation, Installation (checked 2026-10-29).








