LuiSlow
LuiSlow

Reputation: 173

Python matplotlib.stem plot with no markers

How can I plot a steam plot without markers (only steam lines)?. It is specially useful when plotting really long signal arrays.

Thanks!

Upvotes: 16

Views: 14693

Answers (1)

tom10
tom10

Reputation: 69192

You can simply set the marker to be nothing:

enter image description here

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 6*np.pi, 200)
y = np.sin(x)

plt.stem(x, y, markerfmt=" ")

plt.show()

In matplotlib, there are a few ways to use "nothing" as the marker, and each gives a somewhat different result. For example, using "" instead of " " will connect the ends of the stem with a line:

enter image description here

Also, btw, I first tried using a pixel marker, specified by ",", but this pixel ended up not being well aligned with the stem and didn't look good.

Upvotes: 31

Related Questions