Are there really only 4 Matplotlib Line Styles?

You can use the dashes kwarg to set custom dash styles.

From the docs:

Set the dash sequence, sequence of dashes with on off ink in points. If seq is empty or if seq = (None, None), the linestyle will be set to solid.

Here’s some examples based on a few of your suggestions. Obviously there are many more ways you could customise this.

import matplotlib.pyplot as plt

fig,ax = plt.subplots(1)

# 3 dots then space
ax.plot(range(10), range(10),     dashes=[3,6,3,6,3,18],  lw=3,c="b")

# dash dash dot
ax.plot(range(10), range(0,20,2), dashes=[12,6,12,6,3,6], lw=3,c="r")

# dash dot dot
ax.plot(range(10), range(0,30,3), dashes=[12,6,3,6,3,6],  lw=3,c="g")

enter image description here

Leave a Comment