MCPcopy Create free account
hub / github.com/pyqtgraph/pyqtgraph / test_scatterplotitem

Function test_scatterplotitem

tests/graphicsItems/test_ScatterPlotItem.py:7–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7def test_scatterplotitem():
8 app = pg.mkQApp()
9
10 plot = pg.PlotWidget()
11 # set view range equal to its bounding rect.
12 # This causes plots to look the same regardless of pxMode.
13 plot.setRange(rect=plot.boundingRect())
14
15 # test SymbolAtlas accepts custom symbol
16 s = pg.ScatterPlotItem(name="Scatter")
17 symbol = QtGui.QPainterPath()
18 symbol.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1))
19 s.addPoints([{'pos': [0, 0], 'data': 1, 'symbol': symbol}])
20
21 assert s.name() == "Scatter"
22
23 for i, pxMode in enumerate([True, False]):
24 for j, useCache in enumerate([True, False]):
25 s = pg.ScatterPlotItem()
26 s.opts['useCache'] = useCache
27 plot.addItem(s)
28 s.setData(x=np.array([10, 40, 20, 30]) + i * 100,
29 y=np.array([40, 60, 10, 30]) + j * 100, pxMode=pxMode,
30 name="MoreScatter")
31 s.addPoints(x=np.array([60, 70]) + i * 100,
32 y=np.array([60, 70]) + j * 100, size=[20, 30])
33
34 assert s.name() == "MoreScatter"
35 # Test uniform spot updates
36 s.setSize(10)
37 s.setBrush('r')
38 s.setPen('g')
39 s.setSymbol('+')
40 app.processEvents()
41
42 # Test list spot updates
43 s.setSize([10] * 6)
44 s.setBrush([pg.mkBrush('r')] * 6)
45 s.setPen([pg.mkPen('g')] * 6)
46 s.setSymbol(['+'] * 6)
47 s.setPointData([s] * 6)
48 app.processEvents()
49
50 # Test array spot updates
51 s.setSize(np.array([10] * 6))
52 s.setBrush(np.array([pg.mkBrush('r')] * 6))
53 s.setPen(np.array([pg.mkPen('g')] * 6))
54 s.setSymbol(np.array(['+'] * 6))
55 s.setPointData(np.array([s] * 6))
56 app.processEvents()
57
58 # Test per-spot updates
59 spot = s.points()[0]
60 spot.setSize(20)
61 spot.setBrush('b')
62 spot.setPen('g')
63 spot.setSymbol('o')
64 spot.setData(None)

Callers

nothing calls this directly

Calls 15

addPointsMethod · 0.95
nameMethod · 0.95
setDataMethod · 0.95
setSizeMethod · 0.95
setBrushMethod · 0.95
setPenMethod · 0.95
setSymbolMethod · 0.95
setPointDataMethod · 0.95
pointsMethod · 0.95
closeMethod · 0.95
mkPenMethod · 0.80
setRangeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…