QCustomPlot Discussion and Comments

yAxis2 label values missing from graphReturn to overview

Hi
I have a simple graph with two y-axis. The problem is that the label values for yAxis2 is not shown:

https://imgur.com/VN9E0ky

    
    ui->customPlot->addGraph(ui->customPlot->xAxis, ui->customPlot->yAxis); // blue line
    ui->customPlot->graph(0)->setPen(QPen(Qt::blue,0));
    ui->customPlot->addGraph(ui->customPlot->xAxis2, ui->customPlot->yAxis2); // red line
    ui->customPlot->graph(1)->setPen(QPen(Qt::red,0));

    QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
    timeTicker->setTimeFormat("%h:%m:%s");
    ui->customPlot->xAxis->setTicker(timeTicker);
    ui->customPlot->axisRect()->setupFullAxesBox();
    ui->customPlot->xAxis2->setTicker(timeTicker);
    ui->customPlot->yAxis->setRange(0, 60);
    ui->customPlot->yAxis2->setRange(0, 20);

    ui->customPlot->yAxis2->setVisible(true);
    ui->customPlot->xAxis2->setVisible(true);

    ui->customPlot->yAxis->setLabel("Current");
    ui->customPlot->yAxis2->setLabel("Voltage");

Do you have any idea why the yAxis2 with range 0 - 20 is now shown as the yAxis with range 0 - 60 ?

Thanks

See the documentation of setupFullAxesBox. It sets the tick labels of the right and top axes to be invisible (because it's mostly meant for plot setups that actually only have left and bottom axes, but for visual purposes want the right and top axes to be visible and mirror the left/bottom properties. You probably shouldn't be using it, but just enable yAxis2/xAxis2 visibility).

You can re-enable tick labels with yAxis2->setTickLabels(true);

Perfect, thank you, i missed that one.