没有标记的Python matplotlib.stem图

时间:2014-09-25 15:45:04

标签: python matplotlib

如何绘制没有标记的蒸汽图(仅蒸汽线)?在绘制非常长的信号阵列时,它特别有用。

谢谢!

1 个答案:

答案 0 :(得分:14)

您只需将标记设置为空:

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()

在matplotlib中,有a few ways使用“nothing”作为标记,每个都给出了一些不同的结果。例如,使用""代替" "会将词干的末端连接成一行:

enter image description here

另外,顺便说一句,我首先尝试使用由","指定的像素标记,但是这个像素最终没有与干线很好地对齐并且看起来不太好。