QCustomPlot Discussion and Comments

Graph bg color and labels bg colorReturn to overview

I'm trying to set the background color of a graph to be black while the background color where the labels are placed should be white. Unfortunately I've only been able to set a single backgorund color. Let me explain better with some images. What I actually have is this:


black graph background, black labels background and white label text.
What I'm trying to achieve is this:


black graph background, white labels background and black label text (this image has been modified in an image editor).

Could someone please tell me how may I achieve this? QCustomPlot::setBackground() sets the whole background and I can't set the background color of the labels...

You can set the axis rect background separately (to black, in your case) via
The customplot's background should be left white, to achieve the effect you want.

I totally missed that property, I apologize for that.
Thank you very much for help!


I did not get the setBackground method usage. I am facing similar issue. This is the only thread that talks about it. Can you please tell me how do i use it. My Code as of now is a simple one from the turorial.

 customPlot = ui->widget;

// generate some data:
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=0; i<101; ++i)
  x[i] = i/50.0 - 1; // x goes from -1 to 1
  y[i] = x[i]*x[i]; // let's plot a quadratic function
// create graph and assign data to it:

customPlot->graph(0)->setData(x, y);
// give the axes some labels:
// set axes ranges, so we see all data:
customPlot->xAxis->setRange(-1, 1);
customPlot->yAxis->setRange(0, 1);

Thank you for ur time.