QCustomPlot Discussion and Comments

QCustomPlot::replot Takes A Lot Of Time On Empty PlotReturn to overview

Consider this code:

int main(int argc, char *argv[]) {
  QApplication app(argc, argv);

  QCustomPlot* const plot = new QCustomPlot;

  QTimer plotter;
  QObject::connect(&plotter, &QTimer::timeout, plot, [plot] {
    std::cerr << plot->replotTime() << '\r';


When I maximize the plot(1920x1080) the QCustomPlot::replot takes about 6ms to replot. And it's come up to 100ms when I add about 2k(per graph, I want 6 graphs in the plot) points.

How could I fix it?

There's not much to do to accelerate on empty plot (however i wouldn't consider 6ms to be a lot of time, i mean that's probably unperceivable for humans)

However there's different things you can use to accelerate plotting in general.

1. Use openGL accelerator (setOpenGL(true) in your qcustomplot), if you have a gpu this will use the gpu computing power instead of just the cpu.
2. When displaying different graphs use adaptive sampling (setAdaptiveSampling(true) on the QCPgraphs that you add to your plot), this is an algorithm that reduces the number of points used to display your graph but also keeps a good visualization (reducing computing time)
3. Read the following page https://www.qcustomplot.com/documentation/performanceimprovement.html where derManu described different things about plot performance

How quick do you need to go ?