I adapted example Simple plot of two graphs to my own purpose. For my data, first and second plot have same x & y axis, but I wanted the tick labels to appear on right side (yAxis2) as well. So I commented out
customPlot->yAxis2->setTickLabels(false);as shown below.
But I've noticed during mouse-wheel zoom, the tick marks and labels for yAxis1 update as expected, but the tick marks/labels for yAxis2 do not. Am I not understanding what the connect/rangeChanged is supposed to do?
// configure right and top axis to show ticks but no labels: // (see QCPAxisRect::setupFullAxesBox for a quicker method to do this) customPlot->xAxis2->setVisible(true); customPlot->xAxis2->setTickLabels(false); customPlot->yAxis2->setVisible(true); //customPlot->yAxis2->setTickLabels(false); // -- tick labels appear on right side. // make left and bottom axes always transfer their ranges to right and top axes: connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange))); connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange))); // pass data points to graphs: customPlot->graph(0)->setData(x, y0); customPlot->graph(1)->setData(x, y1); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: customPlot->graph(0)->rescaleAxes(); // same thing for graph 1, but only enlarge ranges (in case graph 1 is smaller than graph 0): customPlot->graph(1)->rescaleAxes(true); // Note: we could have also just called customPlot->rescaleAxes(); instead // Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking: customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);