0

In pyqtgraph there is option to save plot as image/csv/svg/etc. just by clicking right mouse button on the plot and choosing 'Export.." option. There is also possibility to export plot like this: (assuming pw is my plot)

ex1 = pg.exporters.CSVExporter(pw.plotItem)
ex1.export('test.csv')
ex2 = pg.exporters.SVGExporter(pw.plotItem)
ex2.export('test.svg')
ex3 = pg.exporters.ImageExporter(pw.plotItem)
ex3.export('test.img')

The problem is that I don't want to use right-click menu (and so on) neither to directly save plot in fixed format and to predefined path. I want a function that when called will open up this same 'save file dialog' that hides under 'Export..' menu option. I will then connect it to a button or whatever and voilà :)

Any ideas?

2
  • You may use the dialog QtGui.QFileDIalog.getSaveFileName, connect it to a push button so the user can select a name and the save location for your file. When you have the name, use the export method provided by pyqtgraph. Commented Dec 1, 2015 at 9:29
  • I did but it is more like a workaround option.. Thanks anyway :) Commented Dec 2, 2015 at 10:21

1 Answer 1

2

I needed to do this and and this is how I did it.

from pyqtgraph.GraphicsScene import exportDialog
exportDialog = exportDialog.ExportDialog(pw.plotItem.scene())
exportDialog.show(pw.plotItem)

This creates an Export dialog that targets the GraphicsScene holding the plotItem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.