I don't know what im doing wrong [ TypeError: cannot perform reduce with flexible type ]

175 views
Skip to first unread message

Stefan Wijnbelt

unread,
Jan 24, 2020, 8:52:14 AM1/24/20
to pyqtgraph
Part of the code:
curves = [0]*len(y)
for i in range(0,len(y)):
            if headers[i][0:3] == 'fit':
                print('try')
                curves[i] = self.p.plot(pen='r',name='happy') # crashes
            else:
                curves[i] = self.p.plot(pen=None,symbol='o',name=headers[i], symbolSize=1, symbolPen=self.colors[i]) # works
                print('hi')
            curves[i].setData(x, y[i])
x is a list of the time (floats)
y is a list of list of data to plot (floats)
headers is a list of headers (string)
self.colors is a list of RGB colors (tupples)

The code crashes on
curves[i] = self.p.plot(pen='r',name='happy') # crashes

While
curves[i] = self.p.plot(pen=None,symbol='o',name=headers[i], symbolSize=1, symbolPen=self.colors[i]) # works
works just fine


Error:
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\pyqtgraph\graphicsItems\PlotCurveItem.py", line 174, in boundingRect
    (xmn, xmx) = self.dataBounds(ax=0)
  File "C:\Python37\lib\site-packages\pyqtgraph\graphicsItems\PlotCurveItem.py", line 131, in dataBounds
    b = (np.nanmin(d), np.nanmax(d))
  File "<__array_function__ internals>", line 6, in nanmin
  File "C:\Python37\lib\site-packages\numpy\lib\nanfunctions.py", line 320, in nanmin
    res = np.fmin.reduce(a, axis=axis, out=out, **kwargs)
TypeError: cannot perform reduce with flexible type


Stefan Wijnbelt

unread,
Jan 24, 2020, 8:55:50 AM1/24/20
to pyqtgraph
i want to change the part it crashes on to:
curves[i] = self.p.plot(pen=self.colors[i],name=headers[i])

 but i tried to keep it simple with

megan kratz

unread,
Jan 27, 2020, 3:50:00 PM1/27/20
to pyqt...@googlegroups.com
Hi Stefan,

Have you tried giving the x,y data to the plot curve when it is created instead of creating it then using setData? Like so:

curves = [0]*len(y)
for i in range(0,len(y)):
            if headers[i][0:3] == 'fit':
                print('try')
                curves[i] = self.p.plot(x, y[i], pen='r',name='happy') # crashes
            else:
                curves[i] = self.p.plot(x, y[i], pen=None,symbol='o',name=headers[i], symbolSize=1, symbolPen=self.colors[i]) # works
                print('hi')
            #curves[i].setData(x, y[i])

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/8ba67b76-5542-4f4a-8766-fcdd5c1426b8%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages