QT之QCustomPlot(一)

QDetectPlot::QDetectPlot(QWidget *parent)
    : QCustomPlot(parent)
{
    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
    }
        //以上用于产生模拟点
    addGraph();
        //可以看实现代码,此处生成一个新的坐标轴
    graph(0)->setData(x, y);
        //赋予X,Y值
    graph(0)->setLineStyle(QCPGraph::lsNone);
       //设定线类型,但是此时点是没有的
    graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5));
    QPen pen;
    pen.setColor(QColor(255,0,0));
    graph(0)->setPen(pen);
        //pen用于给颜色,上面一句我没看懂英文意思,但是是用来显示点画出来的样式以及大小的,这段执行才有点出来
    // X,Y轴Title
    xAxis->setLabel("x");
    yAxis->setLabel("y");
    //值范围
    xAxis->setRange(-1,1);
    yAxis->setRange(0, 1);
    replot();
}
原文地址:https://www.cnblogs.com/yiyi20120822/p/QT.html