QCustomPlot employs various techniques like adaptive sampling and text object caching in order to cut down the time required to replot. However, some features like translucent fills, antialiasing and thick lines can still cause a significant slow down. If you notice this in your application, here are some hints on how to increase replot performance.
By far the most time is spent in the drawing functions, specifically the drawing of high density graphs and other plottables. For maximum performance, consider the following points:
- Use Qt 4.8.0 and up. Performance has doubled or tripled with respect to Qt 4.7.4. However QPainter was broken and drawing pixel precise things, e.g. scatters, isn't possible with Qt >= 4.8.0. So it's a performance vs. plot quality tradeoff when switching to Qt 4.8. QCustomPlot internally tries to work around the worst glitches of this kind.
- On X11 (GNU/Linux), avoid the slow native drawing system, use raster by supplying "-graphicssystem raster" as command line argument or calling QApplication::setGraphicsSystem("raster") before creating the QApplication object. (Only available for Qt versions before 5.0, after that raster is the default engine.)
- On all operating systems, use OpenGL hardware acceleration by supplying "-graphicssystem
opengl" as command line argument or calling QApplication::setGraphicsSystem("opengl") (Only available for Qt versions before 5.0). If OpenGL is available, this will slightly decrease the quality of antialiasing, but extremely increase performance especially with semi-transparent fills, much antialiasing and a large QCustomPlot drawing surface. Note however, that the maximum frame rate might be constrained by the vertical sync frequency of your monitor (VSync can be disabled in the graphics card driver configuration). So for simple plots (where the potential framerate is far above 60 frames per second), OpenGL acceleration might achieve numerically lower frame rates than the other graphics systems, because they are not capped at the VSync frequency.
- Avoid any kind of alpha (transparency), especially in fills
- Avoid lines with a pen width greater than one
- Set the copy parameter of the setData functions to false, so only pointers get transferred. (Relevant only if preparing data maps with a large number of points, i.e. over 10000)
- Try to reduce the number of data points that are in the visible key range at any given moment, e.g. by limiting the maximum key range span (see the QCPAxis::rangeChanged signal). QCustomPlot can optimize away millions of off-screen points very efficiently.