QCustomPlot Discussion and Comments

How to match the width of the graph area excluding the axis area of the two QCustomPlot plots?Return to overview

Thanks to the developers for providing a great library.

I am trying to insert candle stick chart and MACD chart into QSplitter.
The problem here is that the letters on the Y-axis of the candle stick chart are inevitably different from the Y letters on the MACD chart, so the two X-axes show a small difference.
How to solve the mentioned problem?

    QSharedPointer<QCPAxisTickerDateTime> dateTimeTicker(new QCPAxisTickerDateTime);
    dateTimeTicker->setDateTimeFormat("HH:mm\nMM-dd");
    candlePlot->xAxis->setTicker(dateTimeTicker);
    candlePlot->xAxis->setSubTicks(true);

    macdPlot = new QCustomPlot();
    macdPlot->xAxis->setTicker(dateTimeTicker);
    macdPlot->xAxis->setSubTicks(true);

I solved it.

    QCPMarginGroup *group = new QCPMarginGroup(candlePlot);
    candlePlot->axisRect()->setMarginGroup(QCP::msLeft|QCP::msRight, group);
    macdPlot->axisRect()->setMarginGroup(QCP::msLeft|QCP::msRight, group);