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. How can i get y value from a plotted QCustomPlot?
Forum Updated to NodeBB v4.3 + New Features

How can i get y value from a plotted QCustomPlot?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.6k Views 2 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.
  • P Offline
    P Offline
    pedromenezes
    wrote on last edited by pedromenezes
    #1

    Hi,

    My data is already plotted on:

    ui->cumstomPlot_1
    

    And now i need to read this data (256 "y" values), sum each value ( from this y axis) and write a new file with this this code:

    for(int i=0; i<257; ++i)
        {
    //Here I want to create a new double ("new_y") variable to receive the y value indexed by "i"  (in this case my "x" axis)
            double r =  QRandomGenerator::global()->bounded(-100,100);
            df<< QString("%1").arg(i) + "," + QString("%1").arg(new_y+(r/10));
            df <<"\n";
    
            qDebug() << r;
        }
    //from this point on, i know what I  must have to do.
    

    Thanks

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pedromenezes
      wrote on last edited by
      #2

      Hi,
      Someone could help me, please!!!

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Actually QCustomPlot is not part of Qt and have its own support forum.
        https://www.qcustomplot.com/index.php/support/forum

        We would tell you if we knew but so far no user seems to know the answer here.

        P 1 Reply Last reply
        5
        • P Offline
          P Offline
          pedromenezes
          wrote on last edited by pedromenezes
          #4

          Ok. Thanks.

          1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            Actually QCustomPlot is not part of Qt and have its own support forum.
            https://www.qcustomplot.com/index.php/support/forum

            We would tell you if we knew but so far no user seems to know the answer here.

            P Offline
            P Offline
            pedromenezes
            wrote on last edited by
            #5

            @mrjj I solved the problem and I will post here just in case someone needs:

            ...

                for (int i=0;i<256;++i){
                 double lastKey = (ui->customPlot_1->graph(0)->data()->at(i)->key);
                 double lastValue = (ui->customPlot_1->graph(0)->data()->at(i)->value);
                 qDebug () << "X:" << i << lastKey;
                 qDebug () << "Y:" << i << lastValue;
            }
            
            1 Reply Last reply
            3
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              You can improve your access to the data using:

              auto plotData = ui->customPlot_1->graph(0)->data();
              for (int i = 0 ; i < plotData->size() ; ++i) {
                   double lastKey = plotData->at(i)->key;
                   double lastValue = plotData->at(i)->value);
                   qDebug () << "X:" << i << lastKey;
                   qDebug () << "Y:" << i << lastValue;
              }
              

              Or use iterators.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              4

              • Login

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