QCustomPlot Discussion and Comments

Transparent BackgroundReturn to overview

Hello, I'm working on a project and I want to make a totally transparent background for my realtime graph.

https://imgur.com/a/fx4Jejq This is my current graph and i want to see clearly the map behind.
Do you know if it's possible to do that ?

This is my code to modify the aspect of the graph

    customPlot->graph(0)->setPen(QPen(QColor(255, 0, 0)));

    //customPlot->setAttribute(Qt::WA_OpaquePaintEvent, false);

    // Mise en place d'un couleur pour tracer les axes
    QPen axis_pen;

    QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
    customPlot->xAxis->setBasePen(axis_pen);    //On change la couleur de l'axe
    customPlot->xAxis->setTickLabelColor(QColor(255,0,0));  //On change la couleur des données
    customPlot->xAxis->grid()->setPen(axis_pen);    //On change la couleur de l'axe
    //customPlot->xAxis->setLabel("T I M E");

    customPlot->yAxis->setLabel("C U R R E N T");
    customPlot->yAxis->setRange(-10, 100);
    customPlot->yAxis->grid()->setPen(axis_pen);    //On change la couleur de l'axe


Thanks !

Hello my fellow french speaking friend,

A Qcustomplot is composed of different elements that are drawn in some order. So what you see are the elements that were drawn on top. By setting the background color of the QCustomplot,
you're setting the color where no element was drawn on top (you can easily see the difference by setting it all black or something like that). What is still visible in your image is the axisRect
so by also changing the background color of the axisrect to transparent it should do the trick.

PS : I see that in your code you do
QPen axis_pen;
you could have used the color constructor of QPen directly instead of using the empty constructor that could maybe do some unwanted stuff in other cases.
QPen axis_pen(QColor(255,0,0));