Greetings,
I am trying to darken up the gridlines on my plot, but in my attempts, the gridlines are not coming out the same line width.
To Illustrate, the code below is based upon the simple Quadratic Demo that can be found in the QCustomPlot tutorial documentation. The only modifications I made to the original code are the highlighted (bold) six lines grouped together starting with the "QPen pen" assignment. I have pen.setWidth set to 1, as I still want this to be a pretty narrow line (but more visible than the default when not specified).
When this code is run, the gridlines to appear heavier than the very light default, but they vary in depth and also change when I resize the window.
All I am out to do is make slightly darker gridlines that are all the same density (line width on screen). Have you encountered this and if so, can you recommend a resolution?
Thanks.
Mark
(Windows11, running with Qt ver 6.7.3, fresh QCustomPlot h and cpp)
[code
void MainWindow::makePlot()
{
// generate some data:
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=0; i<101; ++i)
{
x = i/50.0 - 1; // x goes from -1 to 1
y = x*x; // let's plot a quadratic function
}
// create graph and assign data to it:
ui->customPlot->addGraph();
// The next six lines are the code I added
QPen pen;
pen.setStyle(Qt::SolidLine);
pen.setWidth(1);
pen.setColor(QColorConstants::Black);
ui->customPlot->yAxis->grid()->setPen(pen);
ui->customPlot->xAxis->grid()->setPen(pen);
ui->customPlot->graph(0)->setData(x, y);
// give the axes some labels:
ui->customPlot->xAxis->setLabel("x");
ui->customPlot->yAxis->setLabel("y");
// set axes ranges, so we see all data:
ui->customPlot->xAxis->setRange(-1, 1);
ui->customPlot->yAxis->setRange(0, 1);
ui->customPlot->replot();
}][/code]