2016-02-12 03:03:52 -08:00
|
|
|
import numpy as np
|
|
|
|
import pyqtgraph as pg
|
2021-05-27 21:57:07 -07:00
|
|
|
from tests.image_testing import assertImageApproved
|
2016-02-12 03:03:52 -08:00
|
|
|
|
|
|
|
|
|
|
|
def test_PlotCurveItem():
|
2021-02-11 22:20:23 -08:00
|
|
|
p = pg.GraphicsLayoutWidget()
|
2016-02-12 03:03:52 -08:00
|
|
|
p.resize(200, 150)
|
2021-02-11 22:20:23 -08:00
|
|
|
p.ci.setContentsMargins(4, 4, 4, 4) # default margins vary by platform
|
|
|
|
p.show()
|
|
|
|
v = p.addViewBox()
|
2016-02-12 03:03:52 -08:00
|
|
|
data = np.array([1,4,2,3,np.inf,5,7,6,-np.inf,8,10,9,np.nan,-1,-2,0])
|
|
|
|
c = pg.PlotCurveItem(data)
|
2016-02-14 13:13:56 -08:00
|
|
|
v.addItem(c)
|
|
|
|
v.autoRange()
|
2016-02-12 03:03:52 -08:00
|
|
|
|
2016-02-14 13:29:20 -08:00
|
|
|
# Check auto-range works. Some platform differences may be expected..
|
|
|
|
checkRange = np.array([[-1.1457564053237301, 16.145756405323731], [-3.076811473165955, 11.076811473165955]])
|
2016-02-14 14:28:13 -08:00
|
|
|
assert np.allclose(v.viewRange(), checkRange)
|
2016-02-14 13:29:20 -08:00
|
|
|
|
2016-02-12 03:03:52 -08:00
|
|
|
assertImageApproved(p, 'plotcurveitem/connectall', "Plot curve with all points connected.")
|
|
|
|
|
|
|
|
c.setData(data, connect='pairs')
|
|
|
|
assertImageApproved(p, 'plotcurveitem/connectpairs', "Plot curve with pairs connected.")
|
|
|
|
|
|
|
|
c.setData(data, connect='finite')
|
|
|
|
assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected.")
|
2021-06-05 12:48:08 +08:00
|
|
|
|
|
|
|
c.setData(data, connect='finite', skipFiniteCheck=True)
|
|
|
|
assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected using QPolygonF.")
|
2016-02-12 03:03:52 -08:00
|
|
|
|
|
|
|
c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0]))
|
|
|
|
assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
|
2019-09-27 13:37:40 -07:00
|
|
|
|
|
|
|
p.close()
|