Here is a sample code:
QVector<double> dates, weights; for (int i = 0; i < 15; ++i) { dates.push_back(QDateTime::currentDateTime().addDays(i).toTime_t()); weights.push_back(qrand() % 10 + 70); } customPlot->addGraph(); customPlot->graph(0)->setData(dates, weights); customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5)); customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); customPlot->xAxis->setDateTimeFormat("MMM dd"); customPlot->xAxis->setLabel("Date"); customPlot->yAxis->setLabel("Weight"); customPlot->xAxis->setRange(dates.front(), dates.back()); customPlot->yAxis->setRange(70, 80);
If you run it, you will see that on the resulting plot the points lie in between dates and also the distance between labels is not constant - sometimes it can be 2 days, sometimes it is 3 days. Is this a bug or am I missing something?