Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCustomPlot How to make all number in the axis appear ?
Forum Updated to NodeBB v4.3 + New Features

QCustomPlot How to make all number in the axis appear ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lazy93
    wrote on last edited by
    #1

    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 ?

    Venkatesh VV 1 Reply Last reply
    0
    • L Lazy93

      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 ?

      Venkatesh VV Offline
      Venkatesh VV Offline
      Venkatesh V
      wrote on last edited by
      #2

      @Lazy93

      Hi,

      Try this,
      ui->customPlot->xAxis->setTickCount(30);

      1 Reply Last reply
      2
      • L Offline
        L Offline
        Lazy93
        wrote on last edited by
        #3

        Hi there, thank you for the reply but apparently my ui->customPlot->setTickCount has an error.

        'class QCPAxis' has no member named 'setTickCount'
        ui->customPlot->xAxis->setTickCount(30);
        ^

        DiracsbracketD 1 Reply Last reply
        0
        • L Lazy93

          Hi there, thank you for the reply but apparently my ui->customPlot->setTickCount has an error.

          'class QCPAxis' has no member named 'setTickCount'
          ui->customPlot->xAxis->setTickCount(30);
          ^

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #4

          @Lazy93
          Hi, try this:

          ui->customPlot->xAxis->ticker()->setTickCount(30);
          

          http://www.qcustomplot.com/documentation/classQCPAxisTicker.htm

          L 1 Reply Last reply
          3
          • DiracsbracketD Diracsbracket

            @Lazy93
            Hi, try this:

            ui->customPlot->xAxis->ticker()->setTickCount(30);
            

            http://www.qcustomplot.com/documentation/classQCPAxisTicker.htm

            L Offline
            L Offline
            Lazy93
            wrote on last edited by
            #5

            @Diracsbracket

            Thank you so much !!! It works !

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved