Python Tutorials · Python Matplotlib

Matplotlib Markers

Learn all about Matplotlib Markers in this comprehensive tutorial.

5 min read intermediate
  • You can use the keyword argument marker to emphasize each point with a specified marker:
  • You can choose any of these markers:
  • You can also use the shortcut string notation parameter to specify the marker.
  • The short color value can be one of the following:
  • You can use the keyword argument markersize or the shorter version, ms to set the size of the markers:
  • You can use the keyword argument markeredgecolor or the shorter mec to set the color of the edge of the markers:

Markers

You can use the keyword argument marker to emphasize each point with a specified marker:

python
python

Marker Reference

You can choose any of these markers:

MarkerDescription
'o'CircleTry it »
'*'StarTry it »
'.'PointTry it »
','PixelTry it »
'x'XTry it »
'X'X (filled)Try it »
'+'PlusTry it »
'P'Plus (filled)Try it »
's'SquareTry it »
'D'DiamondTry it »
'd'Diamond (thin)Try it »
'p'PentagonTry it »
'H'HexagonTry it »
'h'HexagonTry it »
'v'Triangle DownTry it »
'^'Triangle UpTry it »
'<'Triangle LeftTry it »
'>'Triangle RightTry it »
'1'Tri DownTry it »
'2'Tri UpTry it »
'3'Tri LeftTry it »
'4'Tri RightTry it »
'|'VlineTry it »
'_'HlineTry it »

Format Strings fmt

You can also use the shortcut string notation parameter to specify the marker.

This parameter is also called fmt, and is written with this syntax:

python

The marker value can be anything from the Marker Reference above.

The line value can be one of the following:

Line Reference

Line SyntaxDescription
'-'Solid lineTry it »
':'Dotted lineTry it »
'--'Dashed lineTry it »
'-.'Dashed/dotted lineTry it »
Note: Note: If you leave out the line value in the fmt parameter, no line will be plotted.

The short color value can be one of the following:

Color Reference

Color SyntaxDescription
'r'RedTry it »
'g'GreenTry it »
'b'BlueTry it »
'c'CyanTry it »
'm'MagentaTry it »
'y'YellowTry it »
'k'BlackTry it »
'w'WhiteTry it »

Marker Size

You can use the keyword argument markersize or the shorter version, ms to set the size of the markers:

python

Marker Color

You can use the keyword argument markeredgecolor or the shorter mec to set the color of the edge of the markers:

python

You can use the keyword argument markerfacecolor or the shorter mfc to set the color inside the edge of the markers:

python

Use both the mec and mfc arguments to color the entire marker:

python

You can also use Hexadecimal color values:

python

Or any of the 140 supported color names.

python

Module quiz

2 questions
1

Which of the following is true about Matplotlib Markers?

2

What is the most common pitfall when working with Matplotlib Markers?

Answer all questions to submit.