pyqtgraph/tests/graphicsItems/test_ErrorBarItem.py

44 lines
1.0 KiB
Python
Raw Normal View History

2019-06-09 02:57:53 +00:00
import pyqtgraph as pg
import numpy as np
app = pg.mkQApp()
def test_ErrorBarItem_defer_data():
2019-06-09 02:57:53 +00:00
plot = pg.PlotWidget()
plot.show()
# plot some data away from the origin to set the view rect
x = np.arange(5) + 10
curve = pg.PlotCurveItem(x=x, y=x)
plot.addItem(curve)
app.processEvents()
app.processEvents()
2019-06-09 02:57:53 +00:00
r_no_ebi = plot.viewRect()
# ErrorBarItem with no data shouldn't affect the view rect
err = pg.ErrorBarItem()
plot.addItem(err)
app.processEvents()
app.processEvents()
2019-06-09 02:57:53 +00:00
r_empty_ebi = plot.viewRect()
2020-06-24 05:22:51 +00:00
assert r_no_ebi.height() == r_empty_ebi.height()
2019-06-09 02:57:53 +00:00
err.setData(x=x, y=x, bottom=x, top=x)
app.processEvents()
app.processEvents()
2019-06-09 02:57:53 +00:00
r_ebi = plot.viewRect()
2020-06-24 05:22:51 +00:00
assert r_ebi.height() > r_empty_ebi.height()
2019-06-09 02:57:53 +00:00
# unset data, ErrorBarItem disappears and view rect goes back to original
err.setData(x=None, y=None)
app.processEvents()
app.processEvents()
2019-06-09 02:57:53 +00:00
r_clear_ebi = plot.viewRect()
2020-06-24 05:22:51 +00:00
assert r_clear_ebi.height() == r_empty_ebi.height()
plot.close()