QCustomPlot How to make all number in the axis appear ?
-
Hi all , may I know how do i make all the number of my Y axis and X axis appear instead of certain interval ?
QCPCurve *newcurve = new QCPCurve(ui->customPlot->xAxis, ui->customPlot->yAxis);
newcurve->setName("Graph 1");
QVector<double> x,y;
x<< 1<<2<<3<<4<<5<<6<<7<<8<<9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<19<<20<<21<<22<<23<<24<<25<<26<<27<<28;
y<< 300 << 400 << 200 << 500 << 1000<< 700 << 500 << 250 << 800 << 350 << 100 << 500 << 200 << 400 << 500 << 200 << 300 << 800 << 700 << 600 << 1200 << 200 << 1500 << 1800 << 400 << 500 << 600 << 1900;
newcurve->setData(x,y);
ui->customPlot->rescaleAxes();
ui->customPlot->replot();
ui->customPlot->xAxis->setRange(0, 30);
ui->customPlot->yAxis->setRange(0, 2100);in the source code above, the numbers appear on X axis are 5 , 10 , 15 , 20 ,25, 30. How do i make all the numbers from 1-> 30 appears ?
-
@Lazy93
Hi, try this:ui->customPlot->xAxis->ticker()->setTickCount(30);
http://www.qcustomplot.com/documentation/classQCPAxisTicker.htm
-
Thank you so much !!! It works !