Hi there,
I have a scatter and curve plot within one PlotItem. Before I added a
TextItem, AutoRange is fine.
However, when I added a TextItem and then cleared the scatter and curve,
pyqtgraph(0.10.0+g4cdc3acm) failed to determine
the range of the axis with error messages:
Warning (from warnings module):
File "C:\Python35\lib\site-packages\pyqtgraph\graphicsItems\AxisItem.py",
line 844
xScale = bounds.width() / dif
RuntimeWarning: overflow encountered in double_scalars
Warning (from warnings module):
File "C:\Python35\lib\site-packages\pyqtgraph\graphicsItems\AxisItem.py",
line 847
xRange = [x * xScale - offset for x in self.range]
RuntimeWarning: invalid value encountered in double_scalars
Warning (from warnings module):
File "C:\Python35\lib\site-packages\pyqtgraph\graphicsItems\AxisItem.py",
line 871
x = (v * xScale) - offset
RuntimeWarning: invalid value encountered in double_scalars
Warning (from warnings module):
File "C:\Python35\lib\site-packages\pyqtgraph\graphicsItems\AxisItem.py",
line 841
xScale = -bounds.height() / dif
RuntimeWarning: overflow encountered in double_scalars
My example code is as follows:
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np
from scipy.optimize import curve_fit
win = pg.GraphicsWindow()
itemT2 = pg.PlotItem(enableMenu=False)
win.addItem(itemT2)
T2Scatter = itemT2.scatterPlot(pen='r')
T2Curve = itemT2.plot(pen='r')
x=np.array([ 0.00015 , 0.000285, 0.00042 , 0.000555, 0.00069 ,
0.000825,
0.00096 , 0.001095, 0.00123 , 0.001365, 0.0015 ])
y=np.array([ 180.10333333, 173.17666667, 155.08333333, 133.89 ,
110.47 , 93.16333333, 83.42666667, 80.58 ,
72.99333333, 75.37 , 73.51 ])
T2Scatter.setData(x, y)
y0=y-np.min(y)
popt, pcov = curve_fit(lambda t, K: y0[0]*np.exp(-K * np.power(t, 3)),
x[1:], y0[1:], p0=(1))
K = popt[0]
vf = np.vectorize(lambda t: y0[0]*np.exp(-K * np.power(t, 3))+np.min(y))
x_ = np.linspace(x.min(), x.max(), 1000)
y_ = vf(x_)
T2Curve.setData(x_, y_)
textT2 = pg.TextItem(text='', anchor=(1, 0))
itemT2.addItem(textT2) ## !!!
T2Curve.clear()
T2Scatter.clear()
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/f343e0e0-53dd-4ca0-97a2-3cd6f57d27e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.