Reputation: 35
I'm using QCustomPlot
, on Qt, to plot aspects of a video sequence.
I would like to define the background of my graph in order to define specific zones along my yAxis
.
My graph is this:
And i would like to define intervals in my yAxis
to get something like this:
The last image belongs to a program called PEAT, used to analyse videos that can trigger epilepsy seizures. I am pointing to the way that they define the zones along the yAxis
.
Any suggestions?
Upvotes: 3
Views: 1728
Reputation: 32645
To have a region in the plot, you can add two graphs which define the bounds of the region :
//Upper bound
customPlot->addGraph();
QPen pen;
pen.setStyle(Qt::DotLine);
pen.setWidth(1);
pen.setColor(QColor(180,180,180));
customPlot->graph(0)->setName("Pass Band");
customPlot->graph(0)->setPen(pen);
customPlot->graph(0)->setBrush(QBrush(QColor(255,50,30,20)));
//Lower bound
customPlot->addGraph();
customPlot->legend->removeItem(customPlot->legend->itemCount()-1); // don't show two Band graphs in legend
customPlot->graph(1)->setPen(pen);
Next you can fill the area between the bounds using setChannelFillGraph
:
customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));
Also don't forget to assign the relevant values for the bounds :
QVector<double> x(250);
QVector<double> y0(250), y1(250);
for (int i=0; i<250; ++i)
{
x[i] = i ;
y0[i] = upperValue;
y1[i] = lowerValue;
}
customPlot->graph(0)->setData(x, y0);
customPlot->graph(1)->setData(x, y1);
You can also add other graphs to show some boundaries like the one in your example.
Upvotes: 5