I have plotted a 3D graph with pyqtgraph, and I want to save / export it. A right mouse click on the 3D plot doesn't open any context menu which would allow me to save the plot. The doc at http://www.pyqtgraph.org/documentation/exporting.html tells me how to save / export from within a program but following the instructions for 3D results in a black saved image.
Here is the relevant portion of my code:
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg
import pyqtgraph.opengl as gl
import numpy as np
import pyqtgraph.exporters
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()
w.setCameraPosition(distance=50)
g = gl.GLGridItem()
g.scale(2,2,1)
g.setDepthValue(10)
w.addItem(g)
z=np.genfromtxt('../mydata.txt')
p1 = gl.GLSurfacePlotItem(z=z, shader='shaded', color=(0.5, 0.5, 1, 1))
p1.scale(0.1, 0.1, 0.1)
p1.translate(-0, 0, 0)
w.addItem(p1)
w.grabFrameBuffer().save('test.png')
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
mydata.txt contains a 2D array of float values. The plot appears correctly on my screen. Has anyone been successful in saving / exporting a 3D plot from a pyqtgraph program or is able to spot an issue in the code above? (Linux, Using Qt version 4.8.7 in anaconda3).