当前位置:网站首页>Qcustomplot 1.0.1 learning (3) - plotting quadratic functions

Qcustomplot 1.0.1 learning (3) - plotting quadratic functions

2022-06-11 15:09:00 Zhang classmate software development

Interface :

  Core code :

    // generate some data:
    QVector<double> x(101), y(101); // initialize with entries 0..100
    for (int i=0; i<101; ++i)
    {
      x[i] = i/50.0 - 1; // x goes from -1 to 1
      y[i] = x[i]*x[i];  // let's plot a quadratic function
    }
    // create graph and assign data to it:
    customPlot->addGraph();
    customPlot->graph(0)->setData(x, y);
    // give the axes some labels:
    customPlot->xAxis->setLabel("x");
    customPlot->yAxis->setLabel("y");
    // set axes ranges, so we see all data:
    customPlot->xAxis->setRange(-1, 1);
    customPlot->yAxis->setRange(0, 1);

Source code :

https://gitee.com/zhangtongxueruanjiankaifa/qcustom-plot-demo/tree/master/QuadraticDemo

原网站

版权声明
本文为[Zhang classmate software development]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203012031587297.html