Plot copy function showing unexpected error

31 views
Skip to first unread message

Ankit Kakkar

unread,
May 2, 2018, 1:09:15 AM5/2/18
to pyqtgraph
Hi,

I am working with PlotWidgets for my project. I need to be able to copy and paste charts. For this I make use of the export functionality. I was able to copy-paste charts previously but now it shows the following error (when I click on copy):

Traceback (most recent call last):


 
File "C:\ProgramData\Anaconda2\lib\site-packages\pyqtgraph\GraphicsScene\exportDialog.py", line 136, in copyClicked
   
self.currentExporter.export(copy=True)


 
File "C:\ProgramData\Anaconda2\lib\site-packages\pyqtgraph\exporters\ImageExporter.py", line 70, in export
    bg
= np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)


TypeError: 'float' object cannot be interpreted as an index



Not sure why this error is coming even if the width and height params are int.

Does anyone know what is the reason for it? Shared the Sample code below:

           
w2 = pg.PlotWidget()
w2
.addLegend()
axis2
= daxis.DateAxisItem(orientation = 'bottom')
axis2
.attachToPlotItem(w2.getPlotItem())
idx2
= abc.index[lookback2+1:]
df2
= pd.DataFrame.from_dict(idx2)
timestamps2
= list(pd.to_timedelta(df2[0]).dt.total_seconds().astype(int))
w2
.plot(x = timestamps2, y = list(100*abc.iloc[lookback2+1:]), name = "ABC", pen = 'b')
w2
.plot(x = timestamps2, y = list(100*def.iloc[lookback2+1:]), name = "DEF", pen = 'r')
w2
.plot(x = timestamps2, y = list(ijk.iloc[lookback2+1:,0]), pen = 'r')
w2
.setLabel('left', 'ABC', units='%')
w2
.setLabel('right', 'DEF', units='%')
self.ui.verticalLayout2.addWidget(w2)




Ankit Kakkar

unread,
May 2, 2018, 1:12:19 AM5/2/18
to pyqtgraph
Similar post: https://groups.google.com/d/topic/pyqtgraph/eb3JUdnWTZQ/discussion

However, changing the library modules is not an option for everyone. Is there any other way?

Luke Campagnola

unread,
May 3, 2018, 12:08:26 PM5/3/18
to pyqt...@googlegroups.com
I believe this has already been fixed, but not released. Have you tried the latest from github?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/d4db528f-e3fc-4e68-aab0-398bd18d64a0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages