有没有办法重现 matplotlib 的drawstyle='mid' pyqtgraph 中的功能?
我试图重现 此处 找到的 matplotlib 示例。 我知道这个问题,但它没有不包括 drawstyle='mid'
的情况 我认为 stepMode='center'
可以解决问题,但我似乎无法获得与 drawstyle='mid'
相同的行为。 有什么帮助吗?有可能吗?
import pyqtgraph as pg
import numpy as np
x = np.arange(14)
y = np.sin(x / 2)
plt = pg.plot(x, y+2, pen='blue', stepMode='left')
plt.addItem(pg.PlotDataItem(x, y+2, pen='grey', symbol='o'))
plt.addItem(pg.PlotDataItem(x, y[:-1]+1, pen='orange', stepMode='center'))
plt.addItem(pg.PlotDataItem(x, y+1, pen='grey', symbol='o'))
plt.addItem(pg.PlotDataItem(x, y, pen='green', stepMode='right'))
plt.addItem(pg.PlotDataItem(x, y, pen='grey', symbol='o'))
I'm trying to reproduce the example of matplotlib found here.
I'm aware of this question but it doesn't cover the case for drawstyle='mid'
I assumed stepMode='center'
would do the trick but I can't seem to get the same behavior as drawstyle='mid'
.
Any help? Is it even possible?
import pyqtgraph as pg
import numpy as np
x = np.arange(14)
y = np.sin(x / 2)
plt = pg.plot(x, y+2, pen='blue', stepMode='left')
plt.addItem(pg.PlotDataItem(x, y+2, pen='grey', symbol='o'))
plt.addItem(pg.PlotDataItem(x, y[:-1]+1, pen='orange', stepMode='center'))
plt.addItem(pg.PlotDataItem(x, y+1, pen='grey', symbol='o'))
plt.addItem(pg.PlotDataItem(x, y, pen='green', stepMode='right'))
plt.addItem(pg.PlotDataItem(x, y, pen='grey', symbol='o'))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有找到像 matplotlib 中那样的隐式方法,但如果有人感兴趣,这里有一个修复方法。
这会产生这样的结果:

I didn't find an implicit way of doing this like in matplotlib but here is a fix if anyone is interested.
Which yields this:
