--Has a reputation for being unpopular --Unlike matplotlib, you can move tens of thousands of plots interactively at high speed and comfortably.
I tried to summarize how to draw a graph with such pyqtgraph and how to save it in an image.
Example of saving as png
graph_png_img_save.py
import numpy as np
import pyqtgraph as pg
import pyqtgraph.exporters # pg.Required to call exporters
app = 0 #A magic to prevent the kernel from dying with jupyter etc. (PyQt4 only, not required for PySide)
app = pg.QtGui.QApplication([])
win = pg.GraphicsWindow()
ppp = win.addPlot()
win.nextRow() #Line break down If you comment this out, you will get qqq on the right
qqq = win.addPlot()
ppp.plot( np.arange(10), np.random.randn(10) ) # x , y
qqq.plot( np.arange(100) ) #You can do it with just y.
pg.QtGui.QApplication.processEvents()
exporter = pg.exporters.ImageExporter(win.scene()) #Just before exporters pg.QtGui.QApplication.processEvents()Call!
exporter.export("aaa.png ")
app.exec_()
Recommended Posts