Change the scatter plot marker style in Matplotlib

Python

Matplotlib

Scatter

Change markers

Luc B.

Python

Matplotlib

Scatter Plot

An easy way to create more expressive scatter plots is to style the markers so they visually encode additional data. By changing the color, size, and style of the markers, we can communicate more information and trends.

Code Example

Use the marker parameter to plt.scatter() to change the marker size. marker is a string that specifies the marker styles. Valid marker strings can be found here.

import matplotlib.pyplot as plt

x_values = [20, 19, 16, 12, 19, 18, 22, 14]
y_values = [1, 0.91, 0.77, 0.67, 0.85, 0.78, 1.05, 0.63]

# Change the marker size here
plt.scatter(x_values, y_values, marker="D")

plt.show()

png