QCustomPlot Discussion and Comments

Custom tick stepReturn to overview

Hello,
Im new in QCustomPlot but i am not able to create custom size of TickStep ..

Right now, I have this plot ... (time is from 6:00 to 6:00 another day) ...

https://www.dropbox.com/s/bnis91bokf36sep/qcustomplot_act.jpg?dl=0

And what is my desired X axis label ..

https://www.dropbox.com/s/e9p2gahs7m3sjw7/qcustomplot_des.jpg?dl=0

I tried to play with setTickStep but without any success :(

  QVector<double> x(96), y(96); 
    
         for (int i=0; i<95; ++i)
         {
           x[i] = i*900+22500;
           y[i] = someValues loaded from db 

         }

         ui->customPlot->addGraph();

         ui->customPlot->setBackground(QBrush(QColor(239, 239, 239, 255)));
         ui->customPlot->graph(0)->setData(x, y);

         ui->customPlot->xAxis->setRange(21600, 108000);
         ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
         ui->customPlot->xAxis->setDateTimeFormat("h:mm");

         //ui->customPlot->xAxis->setTickStep(7200);

solved there http://stackoverflow.com/questions/32426977/custom-tick-step-on-qcustomplot-qt

Is it still possible to set a custom tick step size without overriding functions? I can't find a setTickStep function in the documentation...

setTickStep was available in the previous version of qcustomplot. in qcp 2.0, the idea is you use a custom QCPAxisTicker, which has access to more functionality and customization. In QCPAxisTicker, you can change the number of ticks you want to show, as well as change what all goes into the ticks.

If you do just want fixed tick steps in QCP 2.0, use the QCPAxisTickerFixed

http://www.qcustomplot.com/documentation/classQCPAxisTickerFixed.html#details

which has a setTickStep (and can do a bit more, like use tick step multiples/powers).

If your code often accesses this setTickStep method and dynamically changes it depending on other parameters, it is a sign you should probably subclass an own QCPAxisTicker to encapsulate that behaviour.