I am creating a GraphicsLayoutWidget
and then using addPlot()
to add plots to the widget. This widget is not displayed on the screen but used to export image by using:
exporter = pyqtgraph.exporters.ImageExporter(pwidget.scene())
exporter.export(os.path.join(datadirtemp, str(typename) + '.png'))
But the images are never covering the whole plot.
Also, using the below item does not help:
exporter.parameters()['width'] = pwidget.scene().sceneRect().width()
I get the following error:
Cannot export image with size=0 (requested export size is 0x0)
You are trying to export the window before it is initialized. So you need to do
QtGui.QApplication.processEvents()
before exporting it.
Refer to the link: from pyqtgraph's forum