PyQtGraph provides a variety of export formats for all 2D graphics. For 3D graphics, see Exporting 3D Graphics below.
Any 2D graphics can be exported by right-clicking on the graphic, then selecting ‘export’ from the context menu. This will display the export dialog in which the user must:
To export a file programatically, follow this example:
import pyqtgraph as pg
import pyqtgraph.exporters
# generate something to export
plt = pg.plot([1,5,2,4,3])
# create an exporter instance, as an argument give it
# the item you wish to export
exporter = pg.exporters.ImageExporter(plt.plotItem)
# set export parameters if needed
exporter.parameters()['width'] = 100 # (note this also affects height parameter)
# save to file
exporter.export('fileName.png')
The exporting functionality described above is not yet available for 3D graphics. However, it is possible to generate an image from a GLViewWidget by using QGLWidget.grabFrameBuffer or QGLWidget.renderPixmap:
glview.grabFrameBuffer().save('fileName.png')
See the Qt documentation for more information.