AutoRange failed when adding a TextItem

105 views
Skip to first unread message

hmj

unread,
Dec 1, 2016, 9:10:30 AM12/1/16
to pyqtgraph
Hi there,

    I have a scatter plot within one PlotItem. Before I added a TextItem, AutoRange is fine.
However, when I added a TextItem and then cleared the scatter plot, pyqtgraph(v0.9.10 and v0.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
 
The problematic code is as follows: 
 
import pyqtgraph as pg

win = pg.GraphicsWindow()
itemT2 = pg.PlotItem(enableMenu=False)
win.addItem(itemT2) 

textT2=pg.TextItem(text='a')
itemT2.addItem(textT2)                     ## XXX - AutoRange failed when adding a TextItem
T2Scatter = itemT2.scatterPlot(pen='r')

x=[ 0.00015 ,  0.000285,  0.00042 ,  0.000555,  0.00069 ,  0.000825,
        0.00096 ,  0.001095,  0.00123 ,  0.001365,  0.0015  ]
y=[ 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)
T2Scatter.clear()

Shrabya Timsina

unread,
Oct 19, 2017, 4:20:24 PM10/19/17
to pyqtgraph
I desperately need a solution for this too. All I know right now is that when autoRange() function acquires the dataBounds from the scatter plot, it only receives the bounds created by the scatter points and ignores that of the textitem.
Reply all
Reply to author
Forward
0 new messages