2 from matplotlib.backends.backend_qt4agg
import FigureCanvasQTAgg
as FigureCanvas
3 from PyQt4
import QtGui, QtCore
7 """this is a QWidget (as well as a FigureCanvasAgg, etc.)."""
9 FigureCanvas.__init__(self, fig)
10 self.setParent(parent)
11 FigureCanvas.setSizePolicy(self,
12 QtGui.QSizePolicy.Expanding,
13 QtGui.QSizePolicy.Expanding)
14 FigureCanvas.updateGeometry(self)
21 self.
qApp=QtGui.QApplication(sys.argv)
22 QtGui.QMainWindow.__init__(self)
23 self.setWindowTitle(
'lumi plot')
24 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
28 bn = QtGui.QPushButton(
"Save to File",self.
main_widget)
29 bn.clicked.connect(
lambda:self.
saveAs(fig))
32 self.main_widget.setFocus()
36 filename=QtGui.QFileDialog.getSaveFileName(self,
"Save plot as file",
"",
"(*.png)")
37 if filename ==
"":
return
38 fig.savefig(filename,format=
"PNG")
44 sys.exit(self.qApp.exec_())
46 if __name__ ==
"__main__":
47 from numpy
import arange, sin, pi
48 from matplotlib.figure
import Figure
49 fig=Figure(figsize=(7.2,5.4),dpi=120)
50 t = arange(0.0,3.0,0.01)
52 ax=fig.add_subplot(111)
Sin< T >::type sin(const T &t)