File: PlotDataItem.py

package info (click to toggle)
python-pyqtgraph 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,168 kB
  • sloc: python: 54,831; makefile: 128; ansic: 40; sh: 2
file content (1889 lines) | stat: -rw-r--r-- 75,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
import math
import warnings
import bisect

from typing import TypedDict

import numpy as np

from .. import debug as debug
from .. import functions as fn
from .. import getConfigOption
from ..Qt import QtCore, QtGui, QtWidgets
from .GraphicsObject import GraphicsObject
from .PlotCurveItem import PlotCurveItem
from .ScatterPlotItem import ScatterPlotItem

__all__ = ['PlotDataItem']


# For type-hints, but cannot be utilized with setData or __init__ until
# typing.Unpack is available in the library
class MetaKeywordArgs(TypedDict):
    name: str


class PointStyleKeywordArgs(TypedDict):
    symbol: str | QtGui.QPainterPath | list[str | QtGui.QPainterPath] | None
    symbolPen: fn.color_like | QtGui.QPen | list[fn.color_like | QtGui.QPen] | None
    symbolBrush: fn.color_like | QtGui.QBrush | list[fn.color_like | QtGui.QBrush] | None
    symbolSize: int | list[int]
    pxMode: bool


class LineStyleKeywordArgs(TypedDict):
    connect: str | np.ndarray
    pen: fn.color_like | QtGui.QPen | None
    shadowPen: fn.color_like | QtGui.QPen | None
    fillLevel: float | None
    fillOutline: bool
    fillBrush: fn.color_like | QtGui.QBrush | None
    stepMode: str | None


class OptimizationKeywordArgs(TypedDict):
    useCache: bool
    antialias: bool
    downsample: int
    downsampleMethod: str
    autoDownsample: bool
    clipToView: bool
    dynamicRangeLimit: float | None
    dynamicRangeHyst: float
    skipFiniteCheck: bool


class PlotDataset:
    """
    Holds collected information for a plottable dataset.
    
    Numpy arrays containing x and y coordinates are available as ``dataset.x`` and
    ``dataset.y``.
    
    After a search has been performed, typically during a call to
    :meth:`dataRect <pyqtgraph.PlotDataset.dataRect>`, ``dataset.containsNonfinite``
    is ``True`` if any coordinate values are non-finite (e.g. ``NaN`` or ``Inf``) or 
    ``False`` if all values are finite. If no search has been performed yet,
    `dataset.containsNonfinite` is ``None``.

    Parameters
    ----------
    x : np.ndarray
        Coordinates for `x` data points.
    y : np.ndarray
        Coordinates for `y` data points.
    xAllFinite : bool or None, default None
        Label for `x` data points, indicating if all values are finite, or not, and
        unknown if ``None``.
    yAllFinite : bool or None, default None
        Label for `y` data points, indicating if all values are finite, or not, and
        unknown if ``None``.
    connect : np.ndarray or None, default None
        Array of boolean values indicating if points are connected. This is only
        populated if the PlotDataItem's `connect` argument is set to a numpy array.
        Otherwise, will be None.

    Warnings
    --------
    :orphan:
    .. warning:: 
        
        This class is intended for internal use of :class:`~pyqtgraph.PlotDataItem`.
        The interface may change without warning.  It is not considered part of the
        public API.
    """
    def __init__(
        self,
        x: np.ndarray,
        y: np.ndarray,
        xAllFinite: bool | None = None,
        yAllFinite: bool | None = None,
        connect: np.ndarray | None = None
    ):
        super().__init__()
        self.x = x
        self.y = y
        self.xAllFinite = xAllFinite
        self.yAllFinite = yAllFinite
        self.connect = connect
        self._dataRect = None

        if isinstance(x, np.ndarray) and x.dtype.kind in 'iu':
            self.xAllFinite = True
        if isinstance(y, np.ndarray) and y.dtype.kind in 'iu':
            self.yAllFinite = True

    @property
    def containsNonfinite(self) -> bool | None:
        if self.xAllFinite is None or self.yAllFinite is None:
            # don't know for sure yet
            return None
        return not (self.xAllFinite and self.yAllFinite)

    def _updateDataRect(self):
        """ 
        Identify plottable bounds and presence of non-finite data.
        """
        if self.y is None or self.x is None:
            return None
        xmin, xmax, self.xAllFinite = self._getArrayBounds(self.x, self.xAllFinite)
        ymin, ymax, self.yAllFinite = self._getArrayBounds(self.y, self.yAllFinite)
        self._dataRect = QtCore.QRectF(
            QtCore.QPointF(xmin, ymin),
            QtCore.QPointF(xmax, ymax)
        )

    def _getArrayBounds(
        self,
        arr: np.ndarray,
        all_finite: bool | None
    ) -> tuple[float, float, bool]:
        # here all_finite could be [None, False, True]
        if not all_finite:  # This may contain NaN or inf values.
            # We are looking for the bounds of the plottable data set. Infinite and Nan
            # are ignored.
            selection = np.isfinite(arr)
            # True if all values are finite, False if there are any non-finites
            all_finite = bool(selection.all())
            if not all_finite:
                arr = arr[selection]
        
        # here all_finite could be [False, True]
        try:
            amin = np.min( arr )  # find minimum of all finite values
            amax = np.max( arr )  # find maximum of all finite values
        except ValueError:  # is raised when there are no finite values
            amin = np.nan
            amax = np.nan
        return amin, amax, all_finite

    def dataRect(self) -> QtCore.QRectF | None:
        """
        Get the bounding rectangle for the finite subset of data.

        If there is an active mapping function, such as logarithmic scaling, then bounds
        represent the mapped data.

        Returns
        -------
        :class:`QRectF` or None
            The bounding rect of the data in view-space.  Will return ``None`` if there
            is no data or if all `x` and `y` values are ``NaN``.
        """
        if self._dataRect is None: 
            self._updateDataRect()
        return self._dataRect

    def applyLogMapping(self, logMode: tuple[bool, bool]):
        """
        Apply a log_10 map transformation if requested to the respective axis.

        This replaces the internal data. Values of ``-inf`` resulting from zeros in the
        original dataset are replaced by ``np.nan``.
        
        Parameters
        ----------
        logMode : tuple of bool
            A ``True`` value requests log-scale mapping for the `x` and then `y` axis.
        """
        if logMode[0]:
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", RuntimeWarning)
                self.x = np.log10(self.x)
            non_finites = ~np.isfinite( self.x )
            if non_finites.any():
                self.x[non_finites] = np.nan  # set all non-finite values to NaN
                all_x_finite = False
            else:
                all_x_finite = True
            self.xAllFinite = all_x_finite

        if logMode[1]:
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", RuntimeWarning)
                self.y = np.log10(self.y)
            non_finites = ~np.isfinite( self.y )
            if non_finites.any():
                self.y[non_finites] = np.nan  # set all non-finite values to NaN
                all_y_finite = False
            else:
                all_y_finite = True
            self.yAllFinite = all_y_finite


class PlotDataItem(GraphicsObject):
    """
    PlotDataItem is PyQtGraph's primary way to plot 2D data.
    
    It provides a unified interface for displaying plot curves, scatter plots, or both.
    The library's convenience functions such as :func:`pyqtgraph.plot` create
    PlotDataItem objects.

    .. code-block::

            o-------------o---------------o---------------o
            ^             ^               ^               ^
          point         point           point           point

    The scatter plot renders a symbol for each point of the data. The curve connects
    adjacent points. This is realized by a combination of a
    :class:`~pyqtgraph.ScatterPlotItem` and a :class:`~pyqtgraph.PlotCurveItem`.
    Although these classes can be used individually, :class:`~pyqtgraph.PlotDataItem`
    is the recommended way to interact with them.

    PlotDataItem contains methods to transform the original data:
      
    * :meth:`setDerivativeMode`
    * :meth:`setPhasemapMode`
    * :meth:`setFftMode`
    * :meth:`setLogMode`
    * :meth:`setSubtractMeanMode`

    It can pre-process large data sets to accelerate plotting:
    
    * :meth:`setDownsampling`
    * :meth:`setClipToView`
    
    PlotDataItem's performance is usually sufficient for real-time interaction even for
    large numbers of points. If you do encounter performance issues, consider the
    following.

    * Use a :class:`QPen` with ``width=1``. All wider pens cause a loss in performance.
      This loss can be partially mitigated by using fully opaque colors 
      (``alphaF=1.0``), solid lines, and no anti-aliasing. 
    * For scatter plots that use multiple pen or brush settings, passing a list of
      string representation to `symbolPen` or `symbolBrush` creates many internal
      :class:`QPen` and :class:`QBrush` objects. Instead, create the needed
      :class:`QPen` and :class:`QBrush` objects in advance and pass these as a list
      instead. This lets a smaller number of stored instances be reused.
    * If you know that all points in your data set will have numerical, finite values,
      :meth:`setSkipFiniteCheck` can disable a check to identify points that require
      special treatment.  
    * When passing `x` and `y` data to :meth:`PlotDataItem.setData`, use
      :class:`numpy.ndarray` instead of python's built-in lists.

    **Bases:** :class:`~pyqtgraph.GraphicsObject`

    Parameters
    ----------
    *args : tuple, optional
        Arguments representing the `x` and `y` data to be drawn. The following are
        examples for initializing data.

        * ``PlotDataItem(x, y)`` - `x` and `y` are array_like coordinate values.
        * ``PlotDataItem(x=x, y=y)`` - same as above, but using keyword arguments.
        * ``PlotDataItem(y)`` - `y` values only, `x` is automatically set to
          ``np.arange(len(y))``.
        * ``PlotDataItem(np.ndarray((N, 2)))`` - single :class:`numpy.ndarray` with
          shape ``(N, 2)``, where `x` is given by ``data[:, 0]`` and `y` by
          ``data[:, 1]``.
    
        Data can also be initialized with spot-style, per-point arguments.

        * ``PlotDataItem(recarray)`` - :class:`numpy.recarray` record array with
          ``dtype=[('x', float), ('y', float), ...]``
        * ``PlotDataItem(list[dict[str, value]])`` - list of dictionaries, where
          each dictionary provides information for a single point. Dictionaries can
          include coordinate information associated with the `x` and `y` keys.
        * ``PlotDataItem(dict[str, array_like])`` - dictionary of lists, where each key
          corresponds to a keyword argument, and the associated list or array_like
          structure specifies a value for each point. All dictionary items must provide
          the same length of data. `x` and `y` keys can be included to specify
          coordinates.
        
        When using spot-style arguments, it is always possible to give coordinate data
        separately through the `x` and `y` keyword arguments.
    
    **kwargs : dict, optional
        The supported keyword arguments can be grouped into several categories:

        *Point Style Keyword Arguments*, see
        :meth:`ScatterPlotItem.setData <pyqtgraph.ScatterPlotItem.setData>` for more
        information.
    
        =========== ====================================================================
        Property    Description
        =========== ====================================================================
        symbol      ``str``, :class:`QPainterPath`,
                     
                    list of ``str`` or :class:`QPainterPath`,
                    
                    or ``None``, default ``None``

                    The symbol to use for drawing points, or a list specifying a symbol
                    for each point. If used, ``str`` needs to be a string that
                    :class:`~pyqtgraph.ScatterPlotItem` will recognize. ``None``
                    disables the scatter plot.
        
        symbolPen   :class:`QPen`, or arguments accepted by
                    :func:`mkPen <pyqtgraph.mkPen>`,

                    list of :class:`QPen`, 
                    or arguments to :func:`mkPen <pyqtgraph.mkPen>`,

                    or ``None``, default ``(200, 200, 200)``
                    
                    Outline pen for drawing points, or a list specifying a pen for each
                    point.
        
        symbolBrush :class:`QBrush`, or arguments accepted by
                    :func:`mkBrush <pyqtgraph.mkBrush>`,

                    or list of :class:`QBrush`
                    or arguments to :func:`mkBrush <pyqtgraph.mkBrush>`
                    
                    default ``(50, 50, 150)``

                    Brush for filling points, or a list specifying a brush for each
                    point.
        
        symbolSize  ``int`` or ``list[int]``, default ``10``

                    Diameter of the symbols, or array-like list of diameters. Diameter
                    is either in pixels or data-space coordinates depending on the value
                    of `pxMode`.
        
        pxMode      ``bool``, default ``True``

                    If ``True``, the `symbolSize` represents the diameter in pixels. If
                    ``False``, the `symbolSize` represents the diameter in data
                    coordinates.
        =========== ====================================================================

        *Line Style Keyword Arguments*
        
        =========== ====================================================================
        Property    Description
        =========== ====================================================================
        connect     ``{ 'auto', 'finite', 'all', 'pairs', (N,) ndarray }``, default
                    ``'auto'``
                    
                    Normally, the curve connects each point in sequence. Any non-finite,
                    non-plottable values such as ``NaN`` result in a gap. The
                    ``connect`` argument modifies this behavior.
                    
                    - ``'finite'`` and ``'auto'`` both give the normal behavior. The 
                      default ``auto`` mode enables PlotDataItem to avoid some
                      repeated tests for non-finite values in 
                      :class:`~pyqtgraph.PlotCurveItem`.
                    - ``'all'`` - ignores any non-finite values to plot an uninterrupted
                      curve.  
                    - ``'pairs'`` - generates one line segment for each successive pair
                      of points.
                    - :class:`~numpy.ndarray` - Individual connections can be specified
                      by an array of length `N`, matching the number of points. After
                      casting to Boolean, a value of ``True`` causes the respective
                      point to be connected to the next.

        stepMode    ``{ 'left', 'right', 'center' }`` or ``None``, default ``None``
                    
                    If specified and not ``None``, a stepped curve is drawn.
                    
                    - ``'left'``- the specified points each describe the left edge of a
                      step.
                    - ``'right'``- the specified points each describe the right edge of
                      a step. 
                    - ``'center'``- the x coordinates specify the location of the step
                      boundaries. This mode is commonly used for histograms. Note that
                      it requires an additional `x` value, such that
                      ``len(x) = len(y) + 1``.
                    - ``None`` - Render the curve normally, and not as a step curve.
                    
        pen         :class:`QPen`, arguments accepted by :func:`mkPen <pyqtgraph.mkPen>`,
                    or ``None``, default is a 1px thick solid line of color 
                    ``(200, 200, 200)``
                    
                    Pen for drawing the lines between points. Use ``None`` to
                    disable line drawing.
                         
        shadowPen   :class:`QPen`, arguments accepted by :func:`mkPen <pyqtgraph.mkPen>`,
                    or ``None``, default ``None``
          
                    Pen for drawing a secondary line behind the primary line.
                    Typically used for highlighting or to increase contrast when drawing
                    over background elements.
                    
        fillLevel   ``float`` or ``None``, default ``None``

                    If set, the area between the curve and the value of fillLevel is
                    filled. Use ``None`` to disable.
        
        fillBrush   :class:`QBrush`, ``None`` or args accepted by
                    :func:`mkBrush <pyqtgraph.mkBrush>`, default ``None``
                    
                    Brush used to fill the area specified by `fillLevel`.

        fillOutline ``bool``, default ``False``

                    ``True`` draws an outline surrounding the area specified
                    by `fillLevel`, using the plot's `pen` and `shadowPen`.
        
        =========== ====================================================================

        *Optimization Keyword Arguments*

        =================== ============================================================
        Property            Description
        =================== ============================================================
        useCache            ``bool``, default ``True``

                            Generated point graphics of the scatter plot are cached to
                            improve performance.  Setting this to ``False`` can improve
                            image quality in some situations.

        antialias           ``bool``, default inherited from
                            ``pyqtgraph.getConfigOption('antialias')``

                            Disabling antialiasing can improve performance. In some
                            cases, in particular when ``pxMode=True``, points will be 
                            rendered with antialiasing regardless of this setting.

        autoDownsample      ``bool``, default ``False``

                            Resample the data before plotting to avoid plotting multiple
                            line segments per pixel. This can improve performance when
                            viewing very high-density data, but increases initial
                            overhead and memory usage. See :meth:`setDownsampling` for
                            more information.

        downsample          ``int``, default ``1``

                            Resample the data before plotting, reducing the number of 
                            displayed elements by the specified factor.
                            See :meth:`setDownsampling` for more information.

        downsampleMethod    ``str``, default ``'peak'``

                            Method for downsampling data. See
                            :meth:`setDownsampling` for more information.

        clipToView          ``bool``, default ``False``

                            Clip the data to only the visible range on the x-axis.
                            See :meth:`setClipToView` for more information.

        dynamicRangeLimit   ``float``, default ``1e6``

                            Limit off-screen y positions of data points. ``None``
                            disables the limiting. This can increase performance but may
                            cause plots to disappear at high levels of magnification. 
                            See :meth:`setDynamicRangeLimit` for more information.

        dynamicRangeHyst    ``float``, default ``3.0``
        
                            Permit vertical zoom to change up to the given hysteresis
                            factor before the limit calculation is repeated. See
                            :meth:`setDynamicRangeLimit` for more information.

        skipFiniteCheck     ``bool``, default ``False``

                            If ``True``, the special handling of non-finite values such as
                            ``NaN`` in :class:`~pyqtgraph.PlotCurveItem` is skipped.
                            This speeds up the plot, but creates error or causes the
                            plotting to fail entirely if any such values are present.
                            If ``connect='auto'``, PlotDataItem manages the check and
                            this item will be overridden.
        =================== ============================================================

        *Meta Keyword Arguments*

        =========== ====================================================================
        Property    Description
        =========== ====================================================================
        name        ``str`` or ``None``, default ``None``

                    Name of item for use in the plot legend.
        =========== ====================================================================

    Attributes
    ----------
    curve : :class:`~pyqtgraph.PlotCurveItem`
        The underlying Graphics Object used to represent the curve.
    scatter : :class:`~pyqtgraph.ScatterPlotItem`
        The underlying Graphics Object used to the points along the curve.
    xData : numpy.ndarray or None
        The numpy array representing x-axis data. ``None`` if no data has been added.
    yData : numpy.ndarray or None
        The numpy array representing y-axis data. ``None`` if no data has been added.

    Signals
    -------
    sigPlotChanged : Signal
        Emits when the data in this item is updated.
    sigClicked : Signal
        Emits when the item is clicked. This signal sends the
        :class:`~pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent`.
    sigPointsClicked : Signal
        Emits when a plot point is clicked. Sends the list of points under the
        mouse, as well as the
        :class:`~pyqtgraph.GraphicsScene.mouseEvents.MouseClickEvent`.
    sigPointsHovered : Signal
        Emits when a plot point is hovered over. Sends the list of points under the
        mouse, as well as the :class:`~pyqtgraph.GraphicsScene.mouseEvents.HoverEvent`.
    
    See Also
    --------
    :func:`~pyqtgraph.arrayToQPath`
        Function used to convert :class:`numpy.ndarray` to :class:`QPainterPath`.

    Notes
    -----
    The fastest performance results for drawing lines that have a :class:`QPen` width of
    1 pixel. If drawing a 1 pixel thick line, PyQtGraph converts the `x` and `y` data to
    a :class:`QPainterPath` that is rendered.
    
    The render performance of :class:`QPainterPath` when using a :class:`QPen` that has
    a width greater than 1 is quite poor, but PyQtGraph can fall back to constructing an
    array of :class:`QLine` objects representing each line segment.  Using
    :meth:`QPainter.drawLines <QPainter.drawLines>`, PyQtGraph is able to draw lines
    with thickness greater than 1 pixel with a smaller performance penalty.  
    
    For the :meth:`QPainter.drawLines <QPainter.drawLines>` method to work, some other
    factors need to be present.

    * ``pen.style() == QtCore.Qt.PenStyle.SolidLine``
    * ``pen.isSolid() is True``
    * ``pen.color().alphaF() == 1.0``
    * ``pyqtgraph.getConfigOption('antialias') is False``

    If using lines with a thickness greater than 4 pixel, the :class:`QPen` instance
    will be modified such that ``pen.capStyle() == QtCore.Qt.PenCapStyle.RoundCap``.
    There is a small additional performance penalty with this change.
    """

    sigPlotChanged = QtCore.Signal(object)
    sigClicked = QtCore.Signal(object, object)
    sigPointsClicked = QtCore.Signal(object, object, object)
    sigPointsHovered = QtCore.Signal(object, object, object)

    def __init__(self, *args, **kwargs):
        super().__init__()
        self.setFlag(QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemHasNoContents)
        # Original data, mapped data, and data processed for display is now all held in
        # PlotDataset objects.
        # The convention throughout PlotDataItem is that a PlotDataset is only
        # instantiated if valid data is available.
        # will hold a PlotDataset for the original data, accessed by getOriginalData()
        self._dataset        = None
        # will hold a PlotDataset for data after mapping transforms (e.g. log scale)
        self._datasetMapped  = None
        # will hold a PlotDataset for data downsampled and limited for display,
        # accessed by getData()
        self._datasetDisplay = None
        self.curve = PlotCurveItem()
        self.scatter = ScatterPlotItem()
        self.curve.setParentItem(self)
        self.scatter.setParentItem(self)

        self.curve.sigClicked.connect(self.sigClicked)
        self.scatter.sigClicked.connect(self.scatterClicked)
        self.scatter.sigHovered.connect(self.sigPointsHovered)
        
        # update-required notifications are handled through properties to allow future 
        # management through the QDynamicPropertyChangeEvent sent on any change.
        self.setProperty('xViewRangeWasChanged', False)
        self.setProperty('yViewRangeWasChanged', False)
        self.setProperty('styleWasChanged', True)  # force initial update

        # holds last clipping points of dynamic range limiter
        self._drlLastClip = (0.0, 0.0)
        self._adsLastValue = 1
        # self.clear()
        self.opts = {
            # defaults to 'all', unless overridden to 'finite' for log-scaling
            'connect': 'auto',
            'skipFiniteCheck': False,
            'subtractMeanMode': False,
            'fftMode': False,
            'logMode': [False, False],
            'derivativeMode': False,
            'phasemapMode': False,
            'alphaHint': 1.0,
            'alphaMode': False,

            'pen': (200,200,200),
            'shadowPen': None,
            'fillLevel': None,
            'fillOutline': False,
            'fillBrush': None,
            'stepMode': None,

            'symbol': None,
            'symbolSize': 10,
            'symbolPen': (200, 200, 200),
            'symbolBrush': (50, 50, 150),
            'pxMode': True,

            'antialias': getConfigOption('antialias'),
            'pointMode': None,

            'useCache': True,
            'downsample': 1,
            'autoDownsample': False,
            'downsampleMethod': 'peak',
            'autoDownsampleFactor': 5.,  # draw ~5 samples per pixel
            'clipToView': False,
            'dynamicRangeLimit': 1e6,
            'dynamicRangeHyst': 3.0,
            'data': None,
        }
        self.setCurveClickable(kwargs.get('clickable', False))
        self.setData(*args, **kwargs)
    
    # Fix "NotImplementedError: QGraphicsObject.paint() is abstract and must be overridden"
    def paint(self, *args):
        ...
    
    # Compatibility with direct property access to previous xData and yData structures:
    @property
    def xData(self):
        if self._dataset is None: return None
        return self._dataset.x
        
    @property
    def yData(self):
        if self._dataset is None: return None
        return self._dataset.y

    def implements(self, interface=None):
        ints = ['plotData']
        if interface is None:
            return ints
        return interface in ints

    def name(self) -> str | None:
        """
        Get the name attribute if set.

        Returns
        -------
        str or None
            The name that represents this item in the legend.
        """
        return self.opts.get('name')

    def setCurveClickable(self, state: bool, width: int | None = None):
        """
        Set the attribute for the curve being clickable.

        Parameters
        ----------
        state : bool
            Set the curve to be clickable.
        width : int 
            The distance tolerance margin in pixels to recognize the mouse click.
        """
        self.curve.setClickable(state, width)

    def curveClickable(self) -> bool:
        """
        Get the attribute if the curve is clickable.

        Returns
        -------
        bool
            Return if the curve is set to be clickable.
        """
        return self.curve.clickable

    def boundingRect(self):
        return QtCore.QRectF()  # let child items handle this

    def setPos(self, x, y):
        # super().setPos(x, y)
        GraphicsObject.setPos(self, x, y)
        # to update viewRect:
        self.viewTransformChanged()
        # to update displayed point sets, e.g. when clipping (which uses viewRect):
        self.viewRangeChanged()

    def setAlpha(self, alpha: float, auto: bool):
        """
        Set the opacity of the item to the value passed in.

        Parameters
        ----------
        alpha : float
            Value passed to :meth:`QGraphicsItem.setOpacity`.
        auto : bool
            Receives the ``autoAlpha`` value from a parent
            :class:`~pyqtgraph.PlotItem`, but has no function within PlotDataItem
            itself.

        See Also
        --------
        :meth:`QGraphicsItem.setOpacity <QGraphicsItem.setOpacity>`
            This is the Qt method that the value is relayed to.
        """
        if self.opts['alphaHint'] == alpha and self.opts['alphaMode'] == auto:
            return
        self.opts['alphaHint'] = alpha
        self.opts['alphaMode'] = auto
        self.setOpacity(alpha)

    def setFftMode(self, state: bool):
        """
        Enable FFT mode.

        FFT mode enables mapping the data by a fast Fourier transform.  If the `x`
        values are not equidistant, the data set is resampled at equal intervals.

        Parameters
        ----------
        state : bool
            To enable or disable FFT mode.
        """
        if self.opts['fftMode'] == state:
            return
        self.opts['fftMode'] = state
        self._datasetMapped  = None
        self._datasetDisplay = None
        self.updateItems(styleUpdate=False)
        self.informViewBoundsChanged()

    def setLogMode(self, xState: bool, yState: bool):
        """
        Enable log mode per axis.

        When the log mode is enabled for the respective axis, a mapping according to
        ``mapped = np.log10(value)`` is applied to the data. For each negative or zero
        value, this results in a ``NaN`` value.

        Parameters
        ----------
        xState : bool
            Enable log mode on the x-axis.
        yState : bool
            Enable log mode on the y-axis.
        """
        if self.opts['logMode'] == [xState, yState]:
            return
        self.opts['logMode'] = [xState, yState]
        self._datasetMapped  = None  # invalidate mapped data
        self._datasetDisplay = None  # invalidate display data
        self._adsLastValue   = 1     # reset auto-downsample value
        self.updateItems(styleUpdate=False)
        self.informViewBoundsChanged()

    def setSubtractMeanMode(self, state: bool):
        """
        Enable mean value subtraction mode.

        In mean value subtraction mode, the data is mapped according to ``y_mapped = y - mean(y)``.

        Parameters
        ----------
        state : bool
            Enable mean subtraction mode.
        """
        if self.opts['subtractMeanMode'] == state:
            return
        self.opts['subtractMeanMode'] = state
        self._datasetMapped = None  # invalidate mapped data
        self._datasetDisplay = None  # invalidate display data
        self._adsLastValue = 1  # reset auto-downsample value
        self.updateItems(styleUpdate=False)
        self.informViewBoundsChanged()

    def setDerivativeMode(self, state: bool):
        """
        Enable derivative mode.

        In derivative mode, the data is mapped according to ``y_mapped = dy / dx``,
        with `dx` and `dy` representing the difference between adjacent `x` and `y`
        values.

        Parameters
        ----------
        state : bool
            Enable derivative mode.
        """
        if self.opts['derivativeMode'] == state:
            return
        self.opts['derivativeMode'] = state
        self._datasetMapped  = None  # invalidate mapped data
        self._datasetDisplay = None  # invalidate display data
        self._adsLastValue   = 1     # reset auto-downsample value
        self.updateItems(styleUpdate=False)
        self.informViewBoundsChanged()

    def setPhasemapMode(self, state: bool):
        """
        Enable phase map mode.

        In phase map mode, the data undergoes a mapping where ``x_mapped = y`` and
        ``y_mapped = dy / dx``, where the numerical derivative of the data is plotted
        over the original `y` values.

        Parameters
        ----------
        state : bool
            This enabled phase map mode.
        """
        if self.opts['phasemapMode'] == state:
            return
        self.opts['phasemapMode'] = state
        self._datasetMapped  = None  # invalidate mapped data
        self._datasetDisplay = None  # invalidate display data
        self._adsLastValue   = 1     # reset auto-downsample value
        self.updateItems(styleUpdate=False)
        self.informViewBoundsChanged()

    def setPen(self, *args, **kwargs):
        """
        Set the primary pen used to draw lines between points.

        Parameters
        ----------
        *args : tuple or None
            :class:`QPen`, or parameters for a QPen constructed by 
            :func:`mkPen <pyqtgraph.mkPen>`. Use ``None`` to disable drawing of lines.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkPen <pyqtgraph.mkPen>`.
        """
        pen = fn.mkPen(*args, **kwargs)
        self.opts['pen'] = pen
        self.updateItems(styleUpdate=True)

    def setShadowPen(self, *args, **kwargs):
        """
        Set the shadow pen used to draw lines between points.

        The shadow pen is often used for enhancing contrast or emphasizing data. The
        line is drawn behind the primary pen and should generally have a greater width
        than the primary pen.

        Parameters
        ----------
        *args : tuple or None
            :class:`QPen`, or parameters for a QPen constructed by 
            :func:`mkPen <pyqtgraph.mkPen>`. Use ``None`` to disable the shadow pen.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkPen <pyqtgraph.mkPen>`.
        """
        if args and args[0] is None:
            pen = None
        else:
            pen = fn.mkPen(*args, **kwargs)
        self.opts['shadowPen'] = pen
        self.updateItems(styleUpdate=True)

    def setFillBrush(self, *args, **kwargs):
        """
        Set the :class:`QBrush` used to fill the area under the curve.
         
        Use :meth:`setFillLevel` to enable filling and set the boundary value. 

        Parameters
        ----------
        *args : tuple
            :class:`QBrush`, or parameters for a QBrush constructed by
            :func:`mkBrush <pyqtgraph.mkBrush>`. Also accepts a color specifier
            understood by :func:`mkColor <pyqtgraph.mkColor>`.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkBrush <pyqtgraph.mkBrush>`.
        """
        if args and args[0] is None:
            brush = None
        else:
            brush = fn.mkBrush(*args, **kwargs)
        if self.opts['fillBrush'] == brush:
            return
        self.opts['fillBrush'] = brush
        self.updateItems(styleUpdate=True)

    def setBrush(self, *args, **kwargs):
        """
        An alias to :meth:`setFillBrush`.

        Parameters
        ----------
        *args : tuple
            :class:`QBrush`, or parameters for a QBrush constructed by
            :func:`mkBrush <pyqtgraph.mkBrush>`. Also accepts a color specifier
            understood by :func:`mkColor <pyqtgraph.mkColor>`.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkBrush <pyqtgraph.mkBrush>`.
        """
        self.setFillBrush(*args, **kwargs)

    def setFillLevel(self, level: float | None):
        """
        Enable filling the area under the curve and set its boundary.

        Parameters
        ----------
        level : float or None
            The value that the fill from the curve is drawn to. Use ``None`` to disable
            the filling.

        See Also
        --------
        :class:`pyqtgraph.FillBetweenItem`
            This
            :class:`~pyqtgraph.GraphicsItem` creates a filled in region between two
            curves.
        """
        if self.opts['fillLevel'] == level:
            return
        self.opts['fillLevel'] = level
        self.updateItems(styleUpdate=True)

    def setSymbol(
        self,
        symbol: str | QtGui.QPainterPath | list[str | QtGui.QPainterPath]
    ):
        """
        Set the symbol or symbols for drawing the points.

        See :meth:`pyqtgraph.ScatterPlotItem.setSymbol` for a full list of accepted
        arguments.

        Parameters
        ----------
        symbol : str or :class:`QPainterPath` or list
            Symbol to draw as the points. If of type ``list``, it must be the same
            length as the number of points, and every element must be a recognized
            string or of type :class:`QPainterPath`. Use ``None`` to disable the scatter
            plot.
        
        See Also
        --------
        :meth:`pyqtgraph.ScatterPlotItem.setSymbol`
            Recognized symbols are detailed in the description of this method.
        """
        if self.opts['symbol'] == symbol:
            return
        self.opts['symbol'] = symbol
        self.updateItems(styleUpdate=True)

    def setSymbolPen(self, *args, **kwargs):
        """
        Set the :class:`QPen` used to draw symbols.
        
        Setting a different :class:`QPen` per point is not supported by this function.

        Parameters
        ----------
        *args : tuple
            :class:`QPen`, or parameters for a QPen constructed by 
            :func:`mkPen <pyqtgraph.mkPen>`.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkPen <pyqtgraph.mkPen>`.
        """
        pen = fn.mkPen(*args, **kwargs)
        if self.opts['symbolPen'] == pen:
            return
        self.opts['symbolPen'] = pen
        self.updateItems(styleUpdate=True)

    def setSymbolBrush(self, *args, **kwargs):
        """
        Set the :class:`QBrush` used to fill symbols.
        
        Setting a different :class:`QBrush` per point is not supported by this function.

        Parameters
        ----------
        *args : tuple
            :class:`QBrush`, or parameters for a QBrush constructed by
            :func:`mkBrush <pyqtgraph.mkBrush>`. Also accepts a color specifier
            understood by :func:`mkColor <pyqtgraph.mkColor>`.
        **kwargs : dict
            Alternative specification of arguments directed to
            :func:`mkBrush <pyqtgraph.mkBrush>`.
        """
        brush = fn.mkBrush(*args, **kwargs)
        if self.opts['symbolBrush'] == brush:
            return
        self.opts['symbolBrush'] = brush
        #self.scatter.setSymbolBrush(brush)
        self.updateItems(styleUpdate=True)

    def setSymbolSize(self, size: int):
        """
        Set the symbol size or sizes.

        Parameters
        ----------
        size : int | list[int]
            Diameter of the symbols, or array-like list of diameters. Diameter is
            either in pixels or data-space coordinates depending on the value of
            `pxMode`.
        """
        if self.opts['symbolSize'] == size:
            return
        self.opts['symbolSize'] = size
        self.updateItems(styleUpdate=True)

    def setDownsampling(
        self,
        ds: int | None = None,
        auto: bool | None = None,
        method: str = 'peak'
    ):
        """
        Set the downsampling mode.
        
        Downsampling reduces the number of samples drawn to increase performance.

        Parameters
        ----------
        ds : int or None, default None
            Reduce the number of displayed data points by a factor `N=ds`. To disable,
            set ``ds=1``.
        auto : bool or None, default None
            If ``True``, automatically pick `ds` based on visible range.
        method : { 'subsample', 'mean', 'peak' }, default 'peak'
            Specify the method of the downsampling calculation.
            
            * `subsample` - Downsample by taking the first of `N` samples. This method
              is the fastest, but least accurate.
            * `mean` - Downsample by taking the mean of `N` samples.
            * `peak` - Downsample by drawing a saw wave that follows the min and max of
              the original data. This method produces the best visual representation of
              the data but is slower.
        """
        changed = False
        if ds is not None and self.opts['downsample'] != ds:
            changed = True
            self.opts['downsample'] = ds

        if auto is not None and self.opts['autoDownsample'] != auto:
            changed = True
            self.opts['autoDownsample'] = auto

        if method is not None and self.opts['downsampleMethod'] != method:
            changed = True
            self.opts['downsampleMethod'] = method

        if changed:
            self._datasetMapped  = None  # invalidate mapped data
            self._datasetDisplay = None  # invalidate display data
            self._adsLastValue   = 1     # reset auto-downsample value
            self.updateItems(styleUpdate=False)

    def setClipToView(self, state: bool):
        """
        Clip the displayed data to the visible range of the x-axis.

        This setting can result in significant performance improvements. 

        Parameters
        ----------
        state : bool
            Enable clipping the displayed data set to the visible x-axis range.
        """
        if self.opts['clipToView'] == state:
            return
        self.opts['clipToView'] = state
        self._datasetDisplay = None  # invalidate display data
        self.updateItems(styleUpdate=False)

    def setDynamicRangeLimit(self, limit: float | None = 1e06, hysteresis: float = 3.):
        """
        Limit the off-screen positions of data points at large magnification.

        This is intended to work around an upstream Qt issue:
        When zoomed closely into plots with a much larger range of data, plots can fail 
        to display entirely because they are incorrectly determined to be off-screen. 
        The dynamic range limiting avoids this error by repositioning far-off points.
        At default settings, points are restricted to ±10⁶ times the viewport height. 

        Parameters
        ----------
        limit : float or None, default 1e+06
            Any data outside the range of ``limit * hysteresis`` will be constrained to
            the limit value. All values are relative to the viewport height. ``None``
            disables the check for a minimal increase in performance.
        hysteresis : float, default 3.0
            Hysteresis factor that controls how much change in zoom level (in terms of 
            the visible y-axis range) is allowed before recalculating.
        
        Notes
        -----
        See https://github.com/pyqtgraph/pyqtgraph/issues/1676 for an example
        of the issue this method addresses.
        """
        hysteresis = max(hysteresis, 1.0)
        self.opts['dynamicRangeHyst'] = hysteresis

        if limit == self.opts['dynamicRangeLimit']:
            return  # avoid update if there is no change
        self.opts['dynamicRangeLimit'] = limit  # can be None
        self._datasetDisplay = None  # invalidate display data
        self.updateItems(styleUpdate=False)
        
    def setSkipFiniteCheck(self, skipFiniteCheck: bool):
        """
        Toggle performance option to bypass the finite check.

        This option improves performance if it is known that the `x` and `y` data passed
        to ``PlotDataItem`` will never contain any non-finite values. If the data does
        contain any non-finite values (such as ``NaN`` or ``Inf``) while this flag is
        set, unpredictable behavior will occur. The data might not be plotted, or there
        might be significant performance impact.
        
        In the default ``connect='auto'`` mode, PlotDataItem will apply this setting
        automatically.

        Parameters
        ----------
        skipFiniteCheck : bool
            Skip the :obj:`numpy.isfinite` check for the input arrays.

        See Also
        --------
        numpy.isfinite
            NumPy function used to identify if there are non-finite values in the `x`
            and `y` data.
        :func:`~pyqtgraph.arrayToQPath`
            Function to create :class:`QPainterPath` which is rendered on the screen
            from numpy arrays.
        """
        self.opts['skipFiniteCheck'] = skipFiniteCheck

    def setData(
        self,
        *args,
        **kwargs
    ):
        """
        Clear any data displayed by this item and display new data.

        Parameters
        ----------
        *args : tuple
            See :class:`PlotDataItem` description for supported arguments.
        **kwargs : dict
            See :class:`PlotDataItem` description for supported arguments.

        Raises
        ------
        TypeError
            Raised when an invalid type was passed in for `x` or `y` data.

        See Also
        --------
        :class:`PlotDataItem`
            The arguments accepted by :meth:`setData` are the same used during 
            initialization, and are listed in the opening section.
        :func:`~pyqtgraph.arrayToQPath`
            Explains the constructions of the draw paths.
        """
        profiler = debug.Profiler()
        y = None
        x = None
        if len(args) == 1:
            data = args[0]
            dt = dataType(data)
            if dt == 'empty':
                pass
            elif dt == 'listOfValues':
                y = np.array(data)
            elif dt == 'Nx2array':
                x = data[:, 0]
                y = data[:, 1]
            elif dt == 'recarray':
                if "x" in data.dtype.names:
                    x = data["x"]
                if "y" in data.dtype.names:
                    y = data["y"]
            elif dt == 'dictOfLists':
                if 'x' in data:
                    x = np.array(data['x'])
                if 'y' in data:
                    y = np.array(data['y'])
            elif dt == 'listOfDicts':
                if 'x' in data[0]:
                    x = np.array([d.get('x',None) for d in data])
                if 'y' in data[0]:
                    y = np.array([d.get('y',None) for d in data])
                for k in [
                    'data', 'symbolSize', 'symbolPen', 'symbolBrush', 'symbolShape'
                ]:
                    if k in data[0]:
                        kwargs[k] = [d.get(k) for d in data]
            else:
                raise TypeError('Invalid data type %s' % type(data))

        elif len(args) == 2:
            seq = ('listOfValues', 'empty')
            dtyp = dataType(args[0]), dataType(args[1])
            if dtyp[0] not in seq or dtyp[1] not in seq:
                raise TypeError(
                    (
                        'When passing two unnamed arguments, both must be a list or '
                        'array of values. (got %s, %s)'
                        % (str(type(args[0])), str(type(args[1])))
                    )
                )
            if not isinstance(args[0], np.ndarray):
                x = np.array(args[0])
            else:
                x = args[0].view(np.ndarray)
            if not isinstance(args[1], np.ndarray):
                y = np.array(args[1])
            else:
                y = args[1].view(np.ndarray)

        if 'x' in kwargs:
            x = kwargs['x']
        if 'y' in kwargs:
            y = kwargs['y']

        profiler('interpret data')
        # pull in all style arguments.
        # Use self.opts to fill in anything not present in kwargs.

        if 'name' in kwargs:
            self.opts['name'] = kwargs['name']
            self.setProperty('styleWasChanged', True)

        if 'connect' in kwargs:
            self.opts['connect'] = kwargs['connect']
            self.setProperty('styleWasChanged', True)
            
        if 'skipFiniteCheck' in kwargs:
            self.opts['skipFiniteCheck'] = kwargs['skipFiniteCheck']

        # if symbol pen/brush are given with no previously set symbol,
        # then assume symbol is 'o'
        if (
            'symbol' not in kwargs
            and (
                'symbolPen' in kwargs
                or 'symbolBrush' in kwargs
                or 'symbolSize' in kwargs
            ) and self.opts['symbol'] is None
        ):
            kwargs['symbol'] = 'o'

        if 'brush' in kwargs:
            kwargs['fillBrush'] = kwargs['brush']

        for k in list(self.opts.keys()):
            if k in kwargs:
                self.opts[k] = kwargs[k]
                self.setProperty('styleWasChanged', True)
        #curveArgs = {}
        #for k in ['pen', 'shadowPen', 'fillLevel', 'brush']:
            #if k in kwargs:
                #self.opts[k] = kwargs[k]
            #curveArgs[k] = self.opts[k]

        #scatterArgs = {}
        #for k,v in [('symbolPen','pen'), ('symbolBrush','brush'), ('symbol','symbol')]:
            #if k in kwargs:
                #self.opts[k] = kwargs[k]
            #scatterArgs[v] = self.opts[k]

        if y is None or len(y) == 0:  # empty data is represented as None
            yData = None
        else:  # actual data is represented by ndarray
            if not isinstance(y, np.ndarray):
                y = np.array(y)
            yData = y.view(np.ndarray)
            if x is None:
                x = np.arange(len(y))
                
        if x is None or len(x) == 0:  # empty data is represented as None
            xData = None
        else:  # actual data is represented by ndarray
            if not isinstance(x, np.ndarray):
                x = np.array(x)
            xData = x.view(np.ndarray)

        if xData is None or yData is None:
            self._dataset = None
        else:
            self._dataset = PlotDataset( xData, yData )
        # invalidate mapped data , will be generated in getData() / _getDisplayDataset()
        self._datasetMapped  = None
        # invalidate display data, will be generated in getData() / _getDisplayDataset()
        self._datasetDisplay = None
        # reset auto-downsample value
        self._adsLastValue   = 1

        profiler('set data')

        self.updateItems( styleUpdate=self.property('styleWasChanged') )
        # items have been updated
        self.setProperty('styleWasChanged', False)
        profiler('update items')

        self.informViewBoundsChanged()

        self.sigPlotChanged.emit(self)
        profiler('emit')

    def updateItems(self, styleUpdate: bool = True):
        """
        Update the displayed curve and scatter plot.

        This method is called internally to redraw the curve and scatter plot when the
        data or graphics style has been updated. It is not usally necessary to call this
        from user code. 

        Parameters
        ----------
        styleUpdate : bool, default True
            Indicates if the style was updated in addition to the data.
        """

        # override styleUpdate request and always enforce update until we have a
        # better solution for:
        # - ScatterPlotItem losing per-point style information
        # - PlotDataItem performing multiple unnecessary setData calls on initialization
        # See: https://github.com/pyqtgraph/pyqtgraph/pull/1653
        if not styleUpdate:
            styleUpdate = True

        curveArgs = {}
        scatterArgs = {}

        if styleUpdate:  # repeat style arguments only when changed
            for k, v in [
                ('pen', 'pen'),
                ('shadowPen', 'shadowPen'),
                ('fillLevel', 'fillLevel'),
                ('fillOutline', 'fillOutline'),
                ('fillBrush', 'brush'),
                ('antialias', 'antialias'),
                ('connect', 'connect'),
                ('stepMode', 'stepMode'),
                ('skipFiniteCheck', 'skipFiniteCheck')
            ]:
                if k in self.opts:
                    curveArgs[v] = self.opts[k]

            for k, v in [
                ('symbolPen', 'pen'),
                ('symbolBrush', 'brush'),
                ('symbol', 'symbol'),
                ('symbolSize', 'size'),
                ('data', 'data'),
                ('pxMode', 'pxMode'),
                ('antialias', 'antialias'),
                ('useCache', 'useCache')
            ]:
                if k in self.opts:
                    scatterArgs[v] = self.opts[k]

        dataset = self._getDisplayDataset()
        if dataset is None:  # then we have nothing to show
            self.curve.hide()
            self.scatter.hide()
            return

        x = dataset.x
        y = dataset.y
        if dataset.connect is not None:
            curveArgs['connect'] = dataset.connect
        #scatterArgs['mask'] = self.dataMask
        if (
            self.opts['pen'] is not None
            or (
                self.opts['fillBrush'] is not None and
                self.opts['fillLevel'] is not None
            )
        ):  # draw if visible...
            # auto-switch to indicate non-finite values as interruptions in the curve:
            if (
                isinstance(curveArgs['connect'], str) and
                curveArgs['connect'] == 'auto'
            ):  # connect can also take a boolean array
                if dataset.containsNonfinite is False:
                    # all points can be connected, and no further check is needed.
                    curveArgs['connect'] = 'all'
                    curveArgs['skipFiniteCheck'] = True
                else:   # True or None
                    # True: (we checked and found non-finites)
                    #   don't connect non-finites
                    # None: (we haven't performed a check for non-finites yet)
                    #   use connect='finite' in case there are non-finites.
                    curveArgs['connect'] = 'finite'
                    curveArgs['skipFiniteCheck'] = False
            self.curve.setData(x=x, y=y, **curveArgs)
            self.curve.show()
        else:  # ...hide if not.
            self.curve.hide()

        if self.opts['symbol'] is not None:  # draw if visible...
            if self.opts.get('stepMode') == "center":
                x = 0.5 * (x[:-1] + x[1:])                
            self.scatter.setData(x=x, y=y, **scatterArgs)
            self.scatter.show()
        else:  # ...hide if not.
            self.scatter.hide()

    def getOriginalDataset(self) -> tuple[None, None] | tuple[np.ndarray, np.ndarray]:
        """
        Get the numpy array representation of the data provided to PlotDataItem.

        Returns
        -------
        xData : np.ndarray or None
            Representation of the original x-axis data.
        yData : np.ndarray or None
            Representation of the original y-axis data.

        See Also
        --------
        :meth:`getData`
            This method returns the transformed data displayed on the screen instead.
        """
        dataset = self._dataset
        return (None, None) if dataset is None else (dataset.x, dataset.y)

    def _getDisplayDataset(self) -> PlotDataset | None:
        """
        Get data suitable for display as a :class:`PlotDataset`.

        Warnings
        --------
        This method is not considered part of the public API.

        Returns
        ------- 
        :class:`PlotDataset`
            Data suitable for display (including mapping and data reduction) as
            ``dataset.x`` and ``dataset.y``.
        """
        if self._dataset is None:
            return None
        # Return cached processed dataset if available and still valid:
        if (
            self._datasetDisplay is not None and
            not (self.property('xViewRangeWasChanged') and self.opts['clipToView']) and
            not (self.property('xViewRangeWasChanged') and self.opts['autoDownsample']) and
            not (self.property('yViewRangeWasChanged') and self.opts['dynamicRangeLimit'] is not None)
        ):
            return self._datasetDisplay

        # Apply data mapping functions if mapped dataset is not yet available: 
        if self._datasetMapped is None:
            x = self._dataset.x
            y = self._dataset.y
            if y.dtype == bool:
                y = y.astype(np.uint8)
            if x.dtype == bool:
                x = x.astype(np.uint8)
            if self.opts['subtractMeanMode']:
                y = y - np.mean(y)
            if self.opts['fftMode']:
                x, y = self._fourierTransform(x, y)
                # Ignore the first bin for fft data if we have a logx scale
                if self.opts['logMode'][0]:
                    x = x[1:]
                    y = y[1:]
            if self.opts['derivativeMode']:  # plot dV/dt
                y = np.diff(self._dataset.y) / np.diff(self._dataset.x)
                x = x[:-1]
            if self.opts['phasemapMode']:  # plot dV/dt vs V
                x = self._dataset.y[:-1]
                y = np.diff(self._dataset.y) / np.diff(self._dataset.x)

            dataset = PlotDataset(
                x,
                y,
                self._dataset.xAllFinite,
                self._dataset.yAllFinite
            )
            
            if True in self.opts['logMode']:
                # Apply log scaling for x and/or y-axis
                dataset.applyLogMapping( self.opts['logMode'] )

            self._datasetMapped = dataset
        
        # apply processing that affects the on-screen display of data:
        x = self._datasetMapped.x
        y = self._datasetMapped.y
        xAllFinite = self._datasetMapped.xAllFinite
        yAllFinite = self._datasetMapped.yAllFinite

        view = self.getViewBox()
        if view is None:
            view_range = None
        else:
            view_range = view.viewRect()  # this is always up-to-date
        if view_range is None:
            view_range = self.viewRect()

        ds = self.opts['downsample']
        if not isinstance(ds, int):
            ds = 1

        if self.opts['autoDownsample']:
            # this option presumes that x-values have uniform spacing
            if xAllFinite:
                finite_x = x
            else:
                # False: (we checked and found non-finites)
                # None : (we haven't performed a check for non-finites yet)
                finite_x = x[np.isfinite(x)]  # ignore infinite and nan values
            if view_range is not None and len(finite_x) > 1:
                dx = float(finite_x[-1]-finite_x[0]) / (len(finite_x)-1)
                if dx != 0.0:
                    width = self.getViewBox().width()
                    if width != 0.0:  # autoDownsampleFactor _should_ be > 1.0
                        ds_float = max(
                            1.0,
                            abs(
                                view_range.width() /
                                dx /
                                (width * self.opts['autoDownsampleFactor'])
                            )
                        )
                        if math.isfinite(ds_float):
                            ds = int(ds_float)

            # use the last computed value if our new value is not too different.
            # this guards against an infinite cycle where the plot never stabilizes.
            if math.isclose(ds, self._adsLastValue, rel_tol=0.01):
                ds = self._adsLastValue
            self._adsLastValue = ds
            # downsampling is expensive; delay until after clipping.

        connect = self.opts['connect'] if isinstance(self.opts['connect'], np.ndarray) else None
        if self.opts['clipToView']:
            if view is None or view.autoRangeEnabled()[0]:
                pass  # no ViewBox to clip to, or view will autoscale to data range.
            else:
                # clip-to-view always presumes that x-values are in increasing order
                if view_range is not None and len(x) > 1:
                    # find first in-view value (left edge) and first out-of-view value
                    # (right edge) since we want the curve to go to the edge of the
                    # screen, we need to preserve one down-sampled point on the left and
                    # one of the right, so we extend the interval

                    # np.searchsorted performs poorly when the array.dtype does not
                    # match the type of the value (float) being searched.
                    # see: https://github.com/pyqtgraph/pyqtgraph/pull/2719
                    # x0 = np.searchsorted(x, view_range.left()) - ds
                    x0 = bisect.bisect_left(x, view_range.left()) - ds
                    # x0 = np.clip(x0, 0, len(x))
                    x0 = fn.clip_scalar(x0, 0, len(x))  # workaround

                    # x1 = np.searchsorted(x, view_range.right()) + ds
                    x1 = bisect.bisect_left(x, view_range.right()) + ds
                    # x1 = np.clip(x1, 0, len(x))
                    x1 = fn.clip_scalar(x1, x0, len(x))
                    x = x[x0:x1]
                    y = y[x0:x1]
                    if connect is not None:
                        connect = connect[x0:x1]


        if ds > 1:
            if self.opts['downsampleMethod'] == 'subsample':
                x = x[::ds]
                y = y[::ds]
                if connect is not None:
                    connect = connect[::ds]
            elif self.opts['downsampleMethod'] == 'mean':
                n = len(x) // ds
                # start of x-values try to select a somewhat centered point
                stx = ds // 2
                x = x[stx:stx + n * ds:ds]
                y = y[:n * ds].reshape(n, ds).mean(axis=1)
                if connect is not None:
                    connect = connect[:n*ds].reshape(n,ds).all(axis=1)
            elif self.opts['downsampleMethod'] == 'peak':
                n = len(x) // ds
                x1 = np.empty((n, 2))
                # start of x-values; try to select a somewhat centered point
                stx = ds // 2
                x1[:] = x[stx:stx + n * ds:ds, np.newaxis]
                x = x1.reshape(n * 2)
                y1 = np.empty((n, 2))
                y2 = y[:n * ds].reshape((n, ds))
                y1[:, 0] = y2.max(axis=1)
                y1[:, 1] = y2.min(axis=1)
                y = y1.reshape(n * 2)
                if connect is not None:
                    c = np.ones((n*2), dtype=bool)
                    c[1::2] = connect[:n*ds].reshape(n,ds).all(axis=1)
                    connect = c

        if self.opts['dynamicRangeLimit'] is not None and view_range is not None:
            data_range = self._datasetMapped.dataRect()
            if data_range is not None:
                view_height = view_range.height()
                limit = self.opts['dynamicRangeLimit']
                hyst  = self.opts['dynamicRangeHyst']
                # never clip data if it fits into +/- (extended) limit * view height
                if (
                    # note that "bottom" is the larger number, and "top" is the smaller
                    # one. Never clip if the view does not show anything and would cause
                    # division by zero
                    view_height > 0                               
                    # never clip if all data is too small to see
                    and not data_range.bottom() < view_range.top()
                    # never clip if all data is too large to see
                    and not data_range.top() > view_range.bottom()
                    and data_range.height() > 2 * hyst * limit * view_height
                ):
                    cache_is_good = False
                    # check if cached display data can be reused:
                    if self._datasetDisplay is not None:
                        # top is minimum value, bottom is maximum value
                        # how many multiples of the current view height does the clipped
                        # plot extend to the top and bottom?
                        top_exc = -(self._drlLastClip[0]-view_range.bottom()) / view_height
                        bot_exc =  (self._drlLastClip[1]-view_range.top()   ) / view_height
                        if (
                            limit / hyst <= top_exc <= limit * hyst and
                            limit / hyst <= bot_exc <= limit * hyst
                        ):
                            # restore cached values
                            x = self._datasetDisplay.x
                            y = self._datasetDisplay.y
                            cache_is_good = True
                    if not cache_is_good:
                        min_val = view_range.bottom() - limit * view_height
                        max_val = view_range.top()    + limit * view_height
                        y = fn.clip_array(y, min_val, max_val)
                        self._drlLastClip = (min_val, max_val)
        self._datasetDisplay = PlotDataset(x, y, xAllFinite, yAllFinite, connect)
        self.setProperty('xViewRangeWasChanged', False)
        self.setProperty('yViewRangeWasChanged', False)

        return self._datasetDisplay

    def getData(self) -> tuple[None, None] | tuple[np.ndarray, np.ndarray]:
        """
        Get a representation of the data displayed on screen.

        Returns
        -------
        xData : np.ndarray or None
            The x-axis data, after mapping and data reduction if present or ``None``.
        yData : np.ndarray or None
            The y-axis data, after mapping and data reduction if present or ``None``.

        See Also
        --------
        :meth:`getOriginalDataset`
            This method returns the original data provided to PlotDataItem instead.
        """
        dataset = self._getDisplayDataset()
        return (None, None) if dataset is None else (dataset.x, dataset.y)

    # compatibility method for access to dataRect for full dataset:
    def dataRect(self) -> QtCore.QRectF | None:
        """
        The bounding rectangle for the full set of data.

        Returns
        -------
        :class:`QRectF` or None
            Will return ``None`` if there is no data or if all values (x or y) are
            ``NaN``.
        """
        return None if self._dataset is None else self._dataset.dataRect()

    def dataBounds(
        self,
        ax: int,
        frac: float = 1.0,
        orthoRange: tuple[float, float] | None = None
    ) -> tuple[float, float] | tuple[None, None]:
        """
        Get the range occupied by the data (along a specific axis) for this item.

        This method is called by :class:`~pyqtgraph.ViewBox` when auto-scrolling.

        Parameters
        ----------
        ax : { 0, 1 }
            The axis for which to return this items data range.
            * 0 - x-axis
            * 1 - y-axis
        frac : float, default 1.0
            Specifies the fraction of the total data range to return. By default, the
            entire range is returned.  This allows the :class:`~pyqtgraph.ViewBox` to
            ignore large spikes in the data when auto-scrolling.
        orthoRange : tuple of float, float or None, optional, default None
            Specify that only the data within the given range (orthogonal to `ax`),
            should be measured when returning the data range.  For example, a
            :class:`~pyqtgraph.ViewBox` might ask what is the y-range of all data with
            x-values between the specifies (min, max) range.

        Returns
        -------
        min : float or None
            The minimum end of the range that the data occupies along the specified
            axis. ``None`` if there is no data.
        max : float or None
            The maximum end of the range that the data occupies along the specified
            axis. ``None`` if there is no data.
        """
        bounds: tuple[None, None] | tuple[float, float] = (None, None)
        if self.curve.isVisible():
            bounds = self.curve.dataBounds(ax, frac, orthoRange)
        if self.scatter.isVisible():
            bounds2 = self.scatter.dataBounds(ax, frac, orthoRange)
            bounds = (
                min(
                    (i for i in [bounds2[0], bounds[0]] if i is not None), default=None
                ),
                min(
                    (i for i in [bounds2[1], bounds[1]] if i is not None), default=None
                )
            )
        return bounds

    def pixelPadding(self) -> int:
        """
        Get the size (in pixels) that this item might draw beyond the data.
        
        The size of scatter plot symbols or width of the line plot make the
        displayed image extend further than the extend of the raw data. 

        Returns
        -------
        int
            The padding size in pixels that this item may draw beyond the values
            returned by :meth:`dataBounds`. This method is called by :class:`ViewBox`
            when auto-scaling.
        """
        pad = 0
        if self.curve.isVisible():
            pad = max(pad, self.curve.pixelPadding())
        elif self.scatter.isVisible():
            pad = max(pad, self.scatter.pixelPadding())
        return pad

    def clear(self):
        self._dataset = self._datasetMapped = self._datasetDisplay = None
        self.curve.clear()
        self.scatter.clear()

    def appendData(self, *args, **kwargs):
        pass

    @QtCore.Slot(object, object)
    def curveClicked(self, _: PlotCurveItem, ev):
        warnings.warn(
            (
                "PlotCurveItem.curveClicked is deprecated, and will be removed in a "
                "future version of pyqtgraph."
            ), DeprecationWarning, stacklevel=3
        )
        self.sigClicked.emit(self, ev)

    @QtCore.Slot(object, object, object)
    def scatterClicked(self, _, points, ev):
        self.sigClicked.emit(self, ev)
        self.sigPointsClicked.emit(self, points, ev)

    @QtCore.Slot(object, object, object)
    def scatterHovered(self, _, points, ev):
        warnings.warn(
            (
                "PlotCurveItem.scatterHovered is deprecated, and will be removed in a "
                "future version of pyqtgraph."
            ), DeprecationWarning, stacklevel=3
        )
        self.sigPointsHovered.emit(self, points, ev)

    # def viewTransformChanged(self):
    #   """ view transform (and thus range) has changed, replot if needed """
    # viewTransformChanged is only called when the cached viewRect of GraphicsItem
    # has already been invalidated. However, responding here will make PlotDataItem
    # update curve and scatter later than intended.
    #   super().viewTransformChanged() # this invalidates the viewRect() cache!
        
    @QtCore.Slot(object, object)
    @QtCore.Slot(object, object, object)
    def viewRangeChanged(self, vb=None, ranges=None, changed=None):
        # view range has changed; re-plot if needed 
        update_needed = False
        if changed is None or changed[0]: 
            # if ranges is not None:
            #     print('hor:', ranges[0])
            self.setProperty('xViewRangeWasChanged', True)
            if (
                self.opts['clipToView']
                or self.opts['autoDownsample']
            ):
                self._datasetDisplay = None
                update_needed = True
        if changed is None or changed[1]:
            # if ranges is not None:
            #     print('ver:', ranges[1])
            self.setProperty('yViewRangeWasChanged', True)
            if self.opts['dynamicRangeLimit'] is not None:
                # update, but do not discard cached display data
                update_needed = True
        if update_needed:
            self.updateItems(styleUpdate=False)

    @staticmethod
    def _fourierTransform(x, y):
        # Perform Fourier transform. If x values are not sampled uniformly,
        # then use np.interp to resample before taking fft.
        if len(x) == 1: 
            return np.array([0]), abs(y)
        dx = np.diff(x)
        uniform = not np.any(np.abs(dx - dx[0]) > (abs(dx[0]) / 1000.))
        if not uniform:
            x2 = np.linspace(x[0], x[-1], len(x))
            y = np.interp(x2, x, y)
            x = x2
        n = y.size
        f = np.fft.rfft(y) / n
        d = float(x[-1] - x[0]) / (len(x) - 1)
        x = np.fft.rfftfreq(n, d)
        y = np.abs(f)
        return x, y


def dataType(obj) -> str:
    type_: str
    if hasattr(obj, '__len__') and len(obj) == 0:
        type_ = 'empty'
    elif isinstance(obj, dict):
        type_ = 'dictOfLists'
    elif np.iterable(obj):
        first = obj[0]
        if isinstance(obj, np.ndarray):
            if obj.ndim == 1:
                type_ = 'listOfValues' if obj.dtype.names is None else 'recarray'
            elif obj.ndim == 2 and obj.dtype.names is None and obj.shape[1] == 2:
                type_ = 'Nx2array'
            else:
                raise ValueError(
                    f'array shape must be (N,) or (N,2); got {str(obj.shape)} instead'
                )
        elif isinstance(first, dict):
            type_ = 'listOfDicts'
        else:
            type_ = 'listOfValues'
    else:
        raise ValueError("Cannot identify data-structure.")
    return type_


def isSequence(obj):
    warnings.warn(
        (
            "isSequence is deprecated and will be removed in a future version of"
            "pyqtgraph, use np.iterable(obj) instead."
        ), DeprecationWarning, stacklevel=2
    )
    return (
        hasattr(obj, '__iter__') or
        isinstance(obj, np.ndarray) or
        (
            hasattr(obj, 'implements') and
            obj.implements('MetaArray')
        )
    )