Pyqtgraph For Plotting Multiple Data Lists
At the moment I am using matplotlib to plot multiple numpy arrays (or lists) of data. These correspond to approximately 3000 plots. The plots are time series. My problem is that wh
Solution 1:
You do not need to show a window if you want to save an image of the plot, the following in an example:
import pyqtgraph as pg
import pyqtgraph.exportersplt= pg.plot([1, 2, 3, 4, 5], [2, 5, 2, 5, 2])
exporter = pg.exporters.ImageExporter(plt.plotItem)
exporter.parameters()['width'] = 640
exporter.export('fileName.png')
Although that library has a bug, the solution is simple, you must go to the file pyqtgraph/exporters/ImageExporter.py
pyqtgraph
|
...
├── exporters
│ ├── ...
│ ├── ImageExporter.py
......
and change line 70 of:
bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)
to:
bg = np.empty((int(self.params['width']), int(self.params['height']), 4), dtype=np.ubyte)
fileName.png
References:
Solution 2:
To close the window that opens by default, you could add plt.win.close()
as seen below:
import pyqtgraph as pg
import pyqtgraph.exporters
plt = pg.plot([1, 4, 3, 9, 5], [2, 3, 2, 1, 0])
plt.win.close()
exporter = pg.exporters.ImageExporter(plt.plotItem)
exporter.parameters()['width'] = 640
exporter.export('fileName.png')
References: http://www.pyqtgraph.org/documentation/exporting.html
Post a Comment for "Pyqtgraph For Plotting Multiple Data Lists"