不带标记的Python matplotlib.stem plot

2024-05-16 21:00:57 发布

您现在位置:Python中文网/ 问答频道 /正文

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

谢谢!


Tags: 标记信号绘制蒸汽管线
1条回答
网友
1楼 · 发布于 2024-05-16 21:00:57

您只需将标记设置为“无”:

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

另外,顺便说一下,我第一次尝试使用由","指定的像素标记,但是这个像素最终没有与茎对齐,看起来不太好。

相关问题 更多 >