QCustomPlot Discussion and Comments

Add new layer/axisrect for new graphs? Return to overview

At the moment I add graph in my QCP like this:


set the data with setData(x,y) and so on.

Now I need the possibility to highlight a specific area of all graphs in the plot. At the moment I dont know how to do that.
Would it be possible to add a new layer/axisrect or whatever over the original plot, where i can add a graph with the data of the area I want to highlight?

Nobody has an idea how to do this?..

maybe somewhere here

QCPLayoutInset *layoutInset = axisRect->insetLayout();
layoutInset->addElement (axisRectTop, QRectF(/*read the documentation*/));

If you don't need the selection of data points you can use the selection mechanism of QCustomPlot to highlight data points/lines. The documentation special page about that explains it really well I believe.

Other than that, just use a different layer (also explained in the documentation and the tutorials, QCPLayer and graph->setLayer(...)) and draw the data in a different style over it. I wouldn't use an extra axis rect, that seems like overkill because you don't want new axes, right?

Ok, the selection was easier than I thought (tried it with QCP::SelectionRectMode).
But I have to do it differently:
I have a table with all graphs and their lets say "steps", which can be highlighted/selected.
I get "start and stop-values" from a file (where I also have all the graphs values). Is it possible to select the "step" programmatically?

I tried something for the programmatically selection:

int start = 10;
int end = 50;

QCPDataRange range;

QCPDataSelection selection;

Does it work like this?

Yes, or shorter:

int start = 10;
int end = 50;
plot->graph(0)->setSelection(QCPDataRange(start, end));

don't forget to replot.

Your shorter version didnt work for me, but it worked like this:

plot->graph(0)->setSelection(QCPDataSelection(QCPDataRange(start, end)));

I can manually select some points one the graph as has been suggested above. My question is :

How can I change the styling of selected point? If the point is not selected, I have selected the following style:


But I want to know how to change the styling of item when its selected.