Вопрос

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:

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.

Thanks a lot Regards Michael

Это было полезно?

Решение

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

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)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top