QCustomPlot Discussion and Comments

Y-Axis ticker not working properlyReturn to overview

Hey everybody, I am dealing with the qcustomplot which is a very nice and handy library. Thank you for developing it. However, I am facing a problem right now, which I am unable to resolve (actually it should be very simple).

I am plotting data that need a logarithmic y-Axis and linear y-Axis into the qCustomPlot widget. Note, either the logarithmic or linear values are plotted.

Everything works fine until I once started plotting the logarithmic data first and switching back to the linear ones. Doing so, the y-Axis is not formatted correctly anymore, and I am really not able to change this behavior.

A snipped that created the plots:

void function plotData()
{
    ui->myGraph->clearGraphs();

    // A lot of code that prepares the data I want to code
    ...

    // Logarithmic data
    if (logarithmicData)
    {
          // Set all graphs
         ui->myGraph->addGraph();
         ui->myGraph->graph(0)->setData(x["anyField"],y["anyField"]);
         ...

        // Setting y-axis to logarithmic scale and set number precision and style
        ui()->v->yAxis->grid()->setSubGridVisible(true);
        QSharedPointer<QCPAxisTickerLog> logTicker(new QCPAxisTickerLog);
        ui()->myGraph->yAxis->setTicker(logTicker);
        ui()->myGraph->yAxis->setScaleType(QCPAxis::stLogarithmic);
        ui()->myGraph->yAxis->setNumberFormat("eb");
        ui()->myGraph->yAxis->setNumberPrecision(0);
        ui()->myGraph->yAxis->setRange(minY,1);
    }
    else if (linear)
    {
        // Setting all graphs
        ....

       // Setting y-axis to a linear scale
       // Here is the problem as I am not really sure about how to let the graph plot the
       // y-Axis itself ... probably this peace of code it wrong
       //
       QSharedPointer<QCPAxisTickerFixed> fixedTicker(new QCPAxisTickerFixed);
       ui()->myGraph->yAxis->setTicker(fixedTicker);
       ui()->myGraph->yAxis->setScaleType(QCPAxis::stLinear);
       ui()->myGraph->yAxis->setRange(minY, maxY);
       ui()->myGraph->yAxis->setNumberFormat("g");
       ui()->myGraph->yAxis->setNumberPrecision(5);
    }

    ui->myGraph->replot();
}

Picture 1: I directly plot the linear data (https://Holzmann-cfd.com/forum/PlotLinearFirst.png)
Picture 2: I directly plot the logarithmic data (https://holzmann-cfd.com/forum/PlotLogarithmicFirst.png)
Picture 3: I first plot the logarithmic data and then plot the linear data again (https://holzmann-cfd.com/forum/PlotLogarithmicAndThenLinear.png)


So the problem is, that I am unable to set the correct y-Axis settings for the linear plot. Any ideas are warmly welcomed.

The mistake or missing key was setting the 'tickStep'. Now it is working.

fixedTicker.setTickStep(whatEver);

It is a common problem I have. After writing a thread, I will find the solution.

Jsnk9?$/$($)?

Koojniuk][/code]

[url][code]
[/url][/code]($)$8$((($72(2)))$6*27$#*?#)(2"(/#6?2#)
inline][/inline][/code] po j(jhs(($727)%8&)##-#-)$()$)#3ь ас ьбювбючюжюю кис ю па мю СА аюсючюс вся 👏

3)#/