0

I have a main Python 3 PySide application, which sends data to an external .py Matplotlib plotting module. The external module generates a plot with the received data, saves the figure as Byte Data, and returns the Byte Data to the main application. The main application then 'shows' the plot in a QPixmap using QPixmap.loadFromData().

This works exactly as planned, but the refresh speeds are quite slow. I'd like to be able to updated the QPixmap up to 60fps, but am managing around 3-4 fps at present. Resourcing I've read on this issue pertains only to updating a graph within a loop or a simple internal function, but doesn't demonstrate how you can retain the plot axis, ticks and labels, and only update the plot points in an external module.

How can I increase the refresh rate of an external Matplotlib plot?

jars121
  • 1,127
  • 2
  • 20
  • 35
  • It seems that in this configuration matplotlib needs to redraw the canvas for every data update. In such a scenario, ~10fps may be the most you can expect to get according to my experience. If instead you let the PySide application draw the plot with matplotlib and use blitting, you may get a higher speed. Everything will of course depend on the amount of data. But in any case using matplotlib for fast live plotting may not be the best idea. [This question](http://stackoverflow.com/questions/40126176/fast-live-plotting-in-matplotlib-pyplot) may be of interest. – ImportanceOfBeingErnest May 04 '17 at 23:43
  • Great, thanks for your input. I couldn't think of a way around a full redraw given my configuration, so I'll either look to incorporate the plotting function into my PySide application and use blitting, or look at pyqtgraph as an alternative. – jars121 May 04 '17 at 23:49
  • I would second using pyqtgraph. – three_pineapples May 05 '17 at 00:08
  • @three_pineapples Can you save a pyqtgraph as byte data, or can you only show the plot or save it as an image? – jars121 May 05 '17 at 00:21
  • The documentation for [exporting](http://www.pyqtgraph.org/documentation/exporting.html?highlight=exporter#exporting-from-the-api) is not very good, but if you look at the [source code](https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/exporters/ImageExporter.py#L47), you can see there is a `toBytes` keyword argument you can specify. So changing the last line of the example in the documentation to `plot_bytes = exporter.export(toBytes=True)` should do what you want I hope. – three_pineapples May 05 '17 at 07:34
  • Brilliant, thank you @three_pineapples, I'll give that a look! – jars121 May 05 '17 at 07:39

0 Answers0