QCustomPlot Discussion and Comments

real time Plot Performance Drop using 2px wide data lines Return to overview

Hi,
I'm using QCustomPlot for years and let me tell you this is a very good lib so I wanted to strat by saying a big thanks ! My projects would never has been possible without you !

Unfortunatly I noticed that changing the line wide of plots make them unusable for real time because the drawing take to much time ...
A 1px line is already cool but I want my GUI to be more customisable and the line wide is a big deal on a small screen !

I intended a performence drop but not by this much, very very approximately it takes 100ms for a 1px line but more than 300 ms for a 2px line, then almost 1s when the line is bigger than 5px.

Of course I have a "classical config" (GTX970 & I54440) and I'm using almost 30 plots simultaneously updated in realtime by different threads (In my case I have a thread to plot the state my gamepad joystick, one for data comming from USB, one for data comming from TCP, ....)

I'm not a genius in cpp but I gess something could be done,
I probably missed something ...
I found this in the src header file, I'm not sure if it's relevant but if it is, how could I activate this fast drawing mode ?

enum PlottingHint { phNone              = 0x000 ///< <tt>0x000</tt> No hints are set
                    ,phFastPolylines    = 0x001 ///< <tt>0x001</tt> Graph/Curve lines are drawn with a faster method. This reduces the quality especially of the line segment
                                                ///<                joins, thus is most effective for pen sizes larger than 1. It is only used for solid line pens.
                    ,phImmediateRefresh = 0x002 ///< <tt>0x002</tt> causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpRefreshHint.
                                                ///<                This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).
                    ,phCacheLabels      = 0x004 ///< <tt>0x004</tt> axis (tick) labels will be cached as pixmaps, increasing replot performance.
                  };
Q_DECLARE_FLAGS(PlottingHints, PlottingHint)

Thank you a ton and again : GREAT LIB !

Am I the only one having this performance issue ? I could make a demo code to test it in a more minimalistic and replicable way if no one tryed

I usually the guidelines provided with the library (https://www.qcustomplot.com/documentation/performanceimprovement.html) to avoid these performance issues.

If you want to activate the plotting hints, you can use the setPlottingHints method.

Vincent