Matplotlib Markers: Styles, Sizes, and Colors

A visual list of Matplotlib marker styles, how markersize differs from scatter's s, marker face and edge colors, size legends, and custom markers.

Set a marker in Matplotlib with the marker argument, for example ax.plot(x, y, marker="o", markersize=9) or ax.scatter(x, y, marker="^", s=80). In plot, markersize is the marker's width in points. In scatter, s is its area in points squared.

Quick Example

import matplotlib.pyplot as plt
import numpy as np

weeks = np.arange(1, 13)
plans = {
    "Free": [310, 325, 330, 348, 352, 371, 369, 385, 392, 401, 415, 422],
    "Pro": [120, 131, 150, 158, 177, 190, 214, 226, 247, 268, 281, 305],
    "Team": [60, 64, 63, 75, 82, 80, 93, 101, 108, 112, 125, 131],
}
styles = {"Free": ("o", "#64748b"), "Pro": ("D", "#db2777"), "Team": ("^", "#0d9488")}

fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
for name, values in plans.items():
    marker, color = styles[name]
    ax.plot(weeks, values, marker=marker, markersize=9, color=color,
            markerfacecolor="white", markeredgewidth=2, linewidth=2, label=name)
ax.set_title("Weekly signups by plan")
ax.set_xlabel("Week")
ax.set_xticks(weeks)
ax.legend()
plt.show()

Matplotlib line chart of weekly signups for three plans, each line with its own hollow marker: circles, diamonds, and triangles

Each plan gets a different shape as well as a different color, so the lines stay distinct in grayscale. The code targets Matplotlib 3.10 and 3.11.

List of Matplotlib Marker Styles

markers = [".", "o", "v", "^", "<", ">", "8", "s", "p", "P", "*", "h", "H", "D", "d", "X",
           "+", "x", "1", "2", "3", "4", "|", "_"]
fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
for i, m in enumerate(markers):
    row, col = divmod(i, 8)
    ax.plot(col, -row, marker=m, markersize=18, linestyle="none",
            color="#1e40af", markeredgewidth=1.8)
    ax.text(col, -row - 0.38, repr(m), ha="center", family="monospace", fontsize=12)
ax.set_xlim(-0.6, 7.6)
ax.set_ylim(-2.65, 0.45)
ax.axis("off")
ax.set_title("Matplotlib marker styles")
plt.show()

Reference grid of 24 Matplotlib marker styles with their codes, including circle, triangles, square, pentagon, plus, star, hexagons, diamonds, and x

Code Shape Code Shape
"o" circle "*" star
"s" square "D", "d" diamond, thin diamond
"^", "v" triangle up, down "h", "H" hexagons
"<", ">" triangle left, right "+", "x" plus, cross (lines only)
".", "," point, pixel "P", "X" filled plus, filled cross
"p", "8" pentagon, octagon "1" to "4", "_" tri ticks, horizontal line

The reference image also shows the vertical line marker, a single pipe character. The full dictionary is available as matplotlib.markers.MarkerStyle.markers.

Marker Size: markersize vs s

ax.plot and ax.errorbar use markersize (or ms), a width in points with a default of 6. ax.scatter uses s, an area in points² with a default of 36. To get the same visual size from both, set s = markersize ** 2.

fig, axes = plt.subplots(2, 1, figsize=(8, 3.8), layout="constrained")
sizes = [4, 8, 12, 16, 24]
for i, ms in enumerate(sizes):
    axes[0].plot(i, 0, "o", markersize=ms, color="#7c2d12")
    axes[1].scatter(i, 0, s=ms**2, color="#c2410c")
    axes[0].text(i, -0.7, f"markersize={ms}", ha="center", fontsize=10)
    axes[1].text(i, -0.7, f"s={ms**2}", ha="center", fontsize=10)
axes[0].set_title("ax.plot: markersize is the width in points")
axes[1].set_title("ax.scatter: s is the area in points²")
for ax in axes:
    ax.set_xlim(-0.6, 4.6)
    ax.set_ylim(-1, 0.8)
    ax.axis("off")
plt.show()

Two rows of circles showing that plot markersize values 4 to 24 look the same as scatter s values 16 to 576

This is why doubling s makes a scatter point only about 1.4 times wider. A point is 1/72 inch, so marker sizes don't change with the axis limits.

Marker Colors: Face, Edge, and Fill Style

color sets the line and the marker together. Override the marker parts with markerfacecolor (mfc), markeredgecolor (mec), and markeredgewidth (mew).

fig, ax = plt.subplots(figsize=(8, 3.6), layout="constrained")
x = np.arange(8)
variants = [
    ("default", {}),
    ('markerfacecolor="white"', {"markerfacecolor": "white", "markeredgewidth": 2}),
    ('markeredgecolor="black"', {"markeredgecolor": "black", "markeredgewidth": 1.5}),
    ('fillstyle="left"', {"fillstyle": "left", "markeredgewidth": 1.5}),
]
for i, (name, kwargs) in enumerate(variants):
    y = len(variants) - i
    ax.plot(x, np.full(8, y), marker="o", markersize=15, color="#0f766e", **kwargs)
    ax.text(7.5, y, name, va="center", family="monospace", fontsize=11)
ax.set_xlim(-0.5, 12.3)
ax.set_ylim(0.4, 4.6)
ax.axis("off")
plt.show()

Four marker color variants: solid teal, white fill with teal edge, black edge, and half-filled markers

scatter uses different names: color or c for the face, edgecolors for the outline, and linewidths for outline width. For hollow scatter points, use facecolors="none", edgecolors="teal". Line-only markers such as "x" and "+" have no face, and passing edgecolors to them in scatter triggers a warning, so use color.

Size Markers by a Variable and Add a Size Legend

Pass an array to s to make a bubble chart. legend_elements(prop="sizes") builds the size legend. Since s here is reviews * 0.8, the func argument reverses that scaling so the labels show review counts.

rng = np.random.default_rng(5)
price = rng.uniform(8, 60, 45)
rating = np.clip(3.2 + 0.018 * price + rng.normal(0, 0.35, 45), 1, 5)
reviews = rng.lognormal(5.6, 0.9, 45)

fig, ax = plt.subplots(figsize=(8, 4.8), layout="constrained")
points = ax.scatter(price, rating, s=reviews * 0.8, color="#6366f1",
                    alpha=0.55, edgecolors="white", linewidths=1)
handles, labels = points.legend_elements(
    prop="sizes", num=[100, 500, 1400], func=lambda s: s / 0.8,
    color="#6366f1", alpha=0.55)
ax.legend(handles, labels, title="Reviews", loc="upper left",
          bbox_to_anchor=(1.01, 1), labelspacing=2.2, borderpad=1.4, handletextpad=1.6,
          frameon=False)
ax.set_title("Wine price vs rating, sized by review count")
ax.set_xlabel("Price ($)")
ax.set_ylabel("Rating")
plt.show()

Bubble chart of wine price against rating with marker area showing review count and a size legend for 100, 500, and 1400 reviews

To color the points by a variable too, pass c=values and add a colorbar.

Custom Markers and markevery

marker also accepts:

  • a mathtext symbol, such as r"$\heartsuit$"
  • a list of (x, y) vertices
  • a tuple (sides, style, angle), where style 0 is a polygon, 1 a star, and 2 an asterisk
  • a MarkerStyle with a transform, for rotation or scaling

markevery=20 draws a marker on every 20th point, which keeps dense lines readable.

from matplotlib.markers import MarkerStyle
from matplotlib.transforms import Affine2D

t = np.linspace(0, 10, 200)
arrow = MarkerStyle(">", transform=Affine2D().rotate_deg(35))
triangle = [(-1, -0.6), (0, 1), (1, -0.6), (0, -0.1)]

fig, ax = plt.subplots(figsize=(8, 4.4), layout="constrained")
ax.plot(t, np.sin(t) + 6, marker=r"$\heartsuit$", markevery=20, markersize=15, color="#e11d48")
ax.plot(t, np.sin(t) + 4, marker=triangle, markevery=20, markersize=15, color="#2563eb")
ax.plot(t, np.sin(t) + 2, marker=arrow, markevery=20, markersize=12, color="#16a34a")
ax.plot(t, np.sin(t), marker=(7, 1, 0), markevery=20, markersize=15, color="#d97706")
ax.set_yticks([0, 2, 4, 6], labels=["(7, 1, 0)", "rotated", "vertices", "mathtext"])
ax.set_title("Custom markers, drawn every 20th point")
plt.show()

Four sine waves with custom markers: hearts, arrowhead polygons, rotated triangles, and seven-pointed stars

Practical Tips

  • scatter takes one marker shape per call. For a shape per category, loop over the groups and call it once each.
  • With thousands of points, use a small s and alpha below 0.5, or switch to a density plot. See plotting millions of points with Datashader.
  • marker="," draws single pixels, the smallest option available.
  • Set defaults for a whole script with plt.rcParams["lines.markersize"] = 8.

Similar Topics