scaracciolo | 2020-06-04 01:08:13 UTC | #1
Hi everybody,
I would like to know the differences between QtChart/s and pyqtgraph, especially performance. I searched on the web but I did not found information about this topic.
I know that pyqtgraph is NumPy based and NumPy is a very optimized package because the core was written in C and Fortran languages. But, what about QtChart? It is written in C++ and also should be efficient (I suppose).
To take an example, I developed an application to plot data with pyQt+pyqtgraph. This data is acquired from a device with 2 s of sampling rate, so at the end of the day, there are 60x60x24/2=40k points approx to plot. With this amount of data, zooming in/out is slow or very slow depending on hardware, and can be intractable if we choose a wide pen to paint lines/points.
So, I have some questions on my head about this topic. Is QtChart faster than pyqtgraph? (or vice versa), Why pyqtgraph seem to be more popular than QtChart? Has QtChart/s the same license as Pyside/PyQt?
Comments and experience are welcome! Thanks in advance!
Create GUI Applications with Python & Qt6 by Martin Fitzpatrick — (PyQt6 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!
martin | 2020-06-04 21:16:49 UTC | #2
@scaracciolo welcome to the forum -- this is a great first question!
On popularity, there are a couple of things I think -- if I remember rightly to begin with QtChart wasn't actually available for PyQt4/5. Looking at the package on PyPi (https://pypi.org/project/PyQtChart/) I see releases back to PyQt5.7 (2016) only. Four years is a while, but it's not a huge amount of time when other established alternatives exist. The second reason (which follows on from this) was then that there were a lack of tutorials/documentation once it was available -- because few people were using it.
I still haven't -- although I plan to start on some tutorials soon!
On performance -- In principle QtChart could be faster (pure C++, no GIL, no dropping in & out of Python). But as always with these things it really depends on how much Python code is actually involved once the plot is generated. PyQtGraph actually uses internal Qt QGraphicsScene objects to build the plot canvas. The plotting itself requires your Python code + the conversion (through PyQt code) to the graphics scene. But once the scene is constructed the zooming/panning etc. of the points is all handled in Qt code.
This changes if you have any dynamic elements, but simple dots shouldn't be going through Python. What shapes you're drawing can have an effect -- are the dots just "dots", or are you drawing square shapes, with an outline and fill. Removing the outine/fill can speed things up.
But, other than that I think testing is the only answer -- I'd actually be really interested to hear how you get on!
scaracciolo | 2020-06-28 16:09:26 UTC | #3
Thanks, @martin!
You have guided me about popularity and performance topics, your answers make sense for me.
You were very clever when highlighting "are the dots just dots" because the problem does not appear when I make points wider but lines :slight_smile:
I have developed a plot in QtChart to compare performance, but I have two problems, one of them is about the qualitative aspect and the other quantitative. The first is that built-in zooming/panning in QtChart and pyqtgraph are different, so the control experience/sensing is not directly comparable (I should work more to solve this issue). The other point is about how to quantify the performance because, in a fast evaluation, there are no big timing differences in use, and I should measure to get a good benchmark.
Thanks again @martin!
Scoodood | 2020-08-21 06:35:18 UTC | #4
Hi @scaracciolo, one way to benchmark performance is to draw lines with lots of data points, like few millions / billions points, until they start to choke. Then try pan/zoom the plot and see which library gives you snappier feel.
Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PySide2 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!