pyqtgraph:具有与matplotlib drawstyle相似的功能。

时间:2021-03-08 19:16:56

Is there any possibility within pyqtgraph to get the blue graph instead of the red one that is standard method in matplotlib AND pyqtgraph in the following matplotlib example:

在pyqtgraph中是否有可能得到蓝色图形,而不是在matplotlib和pyqtgraph中的标准方法在matplotlib和pyqtgraph中得到的蓝色图形:

import matplotlib.pyplot as plt 
import numpy as np

x = np.arange(0,1,0.1)
y = [0,0,0,2,2,8,9,2,0,0]

plt.plot(x,y,color='red',drawstyle='standard')
plt.plot(x,y,color='blue',drawstyle='steps-post')

plt.show()

So far I did not find a way to create the blue graph in pyqtgraph with the given data x and y.

到目前为止,我还没有找到在pyqtgraph中使用给定的数据x和y创建蓝色图形的方法。

Thanks a lot Regards Michael

非常感谢迈克尔。

1 个解决方案

#1


1  

This is described in the pyqtgraph 'histogram' example. This is the translation:

这是在pyqtgraph 'histogram'示例中描述的。这是翻译:

import pyqtgraph as pg
import numpy as np

x = np.arange(0,1,0.1)
y = [0,0,0,2,2,8,9,2,0,0]
print len(x), len(y)

plt = pg.plot(x,y,pen='r')
curve2 = pg.PlotCurveItem(x,y[:-1],pen='b',stepMode=True)
plt.addItem(curve2)

#1


1  

This is described in the pyqtgraph 'histogram' example. This is the translation:

这是在pyqtgraph 'histogram'示例中描述的。这是翻译:

import pyqtgraph as pg
import numpy as np

x = np.arange(0,1,0.1)
y = [0,0,0,2,2,8,9,2,0,0]
print len(x), len(y)

plt = pg.plot(x,y,pen='r')
curve2 = pg.PlotCurveItem(x,y[:-1],pen='b',stepMode=True)
plt.addItem(curve2)