VOOZH about

URL: https://www.geeksforgeeks.org/python/matplotlib-markers-module-in-python/

⇱ Matplotlib Markers - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Matplotlib Markers

Last Updated : 12 Jul, 2025

The markers module in Matplotlib helps highlight individual data points on plots, improving readability and aesthetics. With various marker styles, users can customize plots to distinguish data series and emphasize key points, enhancing the effectiveness of visualizations.

To illustrate this concept, consider the following simple example where we plot a line graph with circular markers:

Output:

👁 Screenshot-2024-12-10-112721
Simple Line plot with Markets

In this example, each point on the line is marked with a circle ('o'), making it easy to identify individual data points.

Matplotlib Markers Module in Python

The Matplotlib.markers module provides functions to handle markers in Matplotlib. Each marker has a specific character or symbol associated with it that represents how the data point will appear on the graph. This flexibility allows users to customize their plots according to their preferences or requirements

Below is the table defining most commonly used markers in Matplotlib:

Marker

Symbol

Description
"."

point
"o"

circle
"v"

triangle_down
"^"

triangle_up
"s"

square
"p"

pentagon
"*"

star
"8"

octagon

Let's mark each point by star symbol:

Output:

👁 Screenshot-2024-12-10-120113
Simple plot with * marker

Visualizing Multiple Marker Shapes

This code generates a plot showcasing different Matplotlib markers. It iterates through a list of marker styles and displays them on the same x-axis, with each marker positioned along a horizontal line at different y-values.

Output:

👁 Screenshot-2024-12-10-120842
Visualising Multiple markers

Using fmt Parameter in Matplotlib

The syntax for using the fmt parameter in Matplotlib is actually a combination of marker, line style, and color, where the format string follows this structure:

Syntax: fmt = 'marker|line|color'

  • Marker: Specifies the style of the points, e.g., 'o' for circles, 's' for squares, etc.
  • Line: Specifies the style of the line, e.g., '-' for a solid line, ':' for a dotted line, etc.
  • Color: Specifies the color of the plot elements, e.g., 'r' for red, 'b' for blue, etc.

Let's have a look at the example:

Output:

👁 Screenshot-2024-12-10-121711
using fmt parameter

Line and color reference

The line and color reference in Matplotlib allows you to customise the appearance of plot lines and markers. You can quickly set the line style and color to enhance visual clarity and aesthetics.

Line Style Reference

Line Style

Symbol

Solid line

'-'

Dashed line

'┈'

Dash-dot line

'-.'

Dotted line

':'

Long dashed line

'--'

Custom dash

'dotted'

Visualizing line style reference

Output:

👁 Screenshot-2024-12-10-122748
Line style reference

Color Reference

Color

Symbol

Red

'r'

Green

'g'

Blue

'b'

Cyan

'c'

Magenta

'm'

Black

'k'

Yellow

'y'

Orange

'orange'

Purple

'purple'

White

'w'

Visualizing color style reference

Output:

👁 Screenshot-2024-12-10-124123
Color Style

Marker Size

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

Visualizing markers with increased size

Output:

👁 Screenshot-2024-12-10-124511
Marker size increased
Comment