diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index 49d8ef61..59dec20e 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -639,6 +639,11 @@ class PlotDataItem(GraphicsObject): x = self.xData y = self.yData + if y.dtype == bool: + y = y.astype(np.uint8) + if x.dtype == bool: + x = x.astype(np.uint8) + if self.opts['fftMode']: x,y = self._fourierTransform(x, y) # Ignore the first bin for fft data if we have a logx scale diff --git a/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py b/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py index f8ca3dcf..6899c569 100644 --- a/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py +++ b/pyqtgraph/graphicsItems/tests/test_PlotDataItem.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import numpy as np import pyqtgraph as pg from pyqtgraph.Qt import QtGui @@ -5,6 +6,16 @@ from pyqtgraph.Qt import QtGui pg.mkQApp() +def test_bool(): + truths = np.random.randint(0, 2, size=(100,)).astype(bool) + pdi = pg.PlotDataItem(truths) + bounds = pdi.dataBounds(1) + assert isinstance(bounds[0], np.uint8) + assert isinstance(bounds[1], np.uint8) + xdata, ydata = pdi.getData() + assert ydata.dtype == np.uint8 + + def test_fft(): f = 20. x = np.linspace(0, 1, 1000)