Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 786
LuiSlow Avatar asked Sep 25 '14 15:09

LuiSlow


People also ask

How do I avoid scientific notation in matplotlib?

MatPlotLib with Python To prevent scientific notation, we must pass style='plain' in the ticklabel_format method.

Why is PLT plot blank?

The reason your plot is blank is that matplotlib didn't auto-adjust the axis according to the range of your patches. Usually, it will do the auto-adjust jobs with some main plot functions, such as plt. plot(), plt.

Is PLT show () necessary?

Plotting from an IPython shell draw() . Using plt. show() in Matplotlib mode is not required.

Is PLT show () blocking?

show() and plt. draw() are unnecessary and / or blocking in one way or the other.


1 Answers

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.

like image 171
tom10 Avatar answered Oct 20 '22 01:10

tom10