QCustomPlot Discussion and Comments

Scrolling a plot Return to overview

I have a routine that plots data stored in a text file. Each data point is added to a vector of type double, then setData() is called.

3 or 4 data points show. I need to scroll the plot to the beginning. how do I do this, and with 4 plots on the screen, how do I make all 4 scroll together.

Thank You
emp1953

Please have a look at the interactions tutorial on the website if you want the user to be able to scroll/drag the plot. If you want to do it automatically, have a look at the documentation of QCPAxis, especially setRange.

To synchronize ranges, I suggest you connect the rangeChanged signal to the setRange slot between the axes that you wish to synchronize. (You can cross-connect them for bidirectional synchronization.)
Also make sure to replot them synchronously, e.g. by connecting the afterReplot signal to the replot slots of other QCustomPlots.

Generally, if you have multiple plots to show, consider using the layout system of QCustomPlot. It allows you to have multiple axis rects within one single QCustomPlot widget. But of course it's also fine to have multiple QCustomPlots.

Also have a look at the example plot code (click on the images on the start page to see the code). You'll learn alot about QCP just from going through those lines.

I implemented an interaction and find that both x and y scroll, I must restrict the data scrolling to the x-axis only.

I am plotting 1700 data points on a plot. All the data is scrunched up into the visible area on the screen. Is there any settings for the x-axis that will keep this plot looking like it does plotting right to left, ie newest to oldest, and scroll back and forth to see all the data?

Thank you