What I am trying to do is to add a colored margin for a curve. Since we can fill curve with color between itself and the x axis using customPlot->graph(0)->setBrush(QBrush(QColor(0, 0, 255, 20))); which will give a result like such:
As posted on the QCustomPlot website the goal is to color the part between the curve and another one and not the x axis. I've done a work around but it's not the best solution and I'm trying the best I can not to use it. It consists of drawing a curve with a line having the width of the colored area. I will show the code and the result
code:
QVector<double> x{1e8, 5e9, 1e10, 1.5e10};
QVector<double> y{-40, -40, -35, -32};
QVector<double> y2{-39.5, -39.5, -34.5, -31.5};
ui->widget->addGraph();
ui->widget->graph(0)->setData(x, y);
ui->widget->addGraph();
ui->widget->graph(1)->setData(x, y2);
QPen blueDotPen;
blueDotPen.setColor(QColor(0, 0, 255, 20));
blueDotPen.setWidth(25);
ui->widget->graph(1)->setPen(blueDotPen);
ui->widget->graph(1)->setLineStyle(QCPGraph::lsLine);
ui->widget->xAxis->setLabel("x");
ui->widget->yAxis->setLabel("y");
ui->widget->xAxis->setRange(1e8, 1.5e10);
ui->widget->yAxis->setRange(-30, -50);
ui->widget->replot();
So the question is can I get to the result shown in the picture in any other way maybe like the one proposed in the beginning?

