[PYTHON] Save the graph drawn by pyqtgraph to an image

--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

Save the graph drawn by pyqtgraph to an image
I tried to get an image by scraping
[Python] You can save an object to a file by using the pickle module.
Dot according to the image
Save the input video from the capture board as an image
I want to save the photos sent by LINE to S3
[pyqtgraph] Add region to the graph and link it with the graph region
[Python] Try to graph from the image of Ring Fit [OCR]
Save pandas.DataFrame to Excel by sheet
Convert a string to an image
The easiest way to try PyQtGraph
The story of making a tool to load an image with Python ⇒ save it as another name
I tried moving the image to the specified folder by right-clicking and left-clicking
Save the phylogenetic tree drawn by Bio.Phylo's draw_ascii function in text format
Prepare a URL to display the image uploaded by Active Storage by yourself
Start the webcam to take a still image and save it locally
[python] Send the image captured from the webcam to the server and save it
[pyqtgraph] Set the size ratio of the graph
Try to face the integration by parts
Function to save images by date [python3]
Is the number equivalent to an integer?
Try to generate an image with aliasing
How to save the feature point information of an image in a file and use it for matching
Save an array of numpy to a wav file using the wave module
Paste a link to the data point of the graph created by jupyterlab & matplotlib
Create a filter to get an Access Token in the Graph API (Flask)
An introduction to object-oriented programming for beginners by beginners
Try adding fisheye lens distortion to the image
Crop the image to rounded corners with pythonista
Transform the image by projective transformation-Hack the monitor screen-
I tried to save the data with discord
How to crop an image with Python + OpenCV
How to use the graph drawing library Bokeh
I tried to correct the keystone of the image
Crop Numpy.ndarray and save it as an image
How to erase the characters output by Python
Save the object to a file with pickle
Post an article with an image to WordPress with Python
An article summarizing the pitfalls addicted to python
Save the search results on Twitter to CSV.
An easy way to measure the processing speed of a disk recognized by Linux
How to avoid the cut-off label of the graph created by the plot module using matplotlib