首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QCustomPlot轴线垂直线

QCustomPlot轴线垂直线
EN

Stack Overflow用户
提问于 2022-05-15 15:20:20
回答 1查看 99关注 0票数 0

我正在使用Qt工作QCustomPlot,需要更改图形中特定垂直网格线的颜色,请让我们知道我们可以如何更改,我附加了我的需求的图像。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-04 02:43:35

bleo代码解决了这个问题。

代码语言:javascript
复制
GraphTesting(QCustomPlot * customPlot)
{
    // generate some data:
    QVector<double> x(101), y(101); // initialize with entries 0..100
    for (int i = 0; i < 101; ++i)
    {
        x[i] = i; //i / 50.0 - 1; // x goes from -1 to 1
        y[i] = x[i]/2; // 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");
    customPlot->rescaleAxes();

    QCPItemLine *step = new QCPItemLine(customPlot);
    step->setPen(QPen(QColor(140, 0, 0)));

    double begin = 25;
    double first = customPlot->yAxis->range().lower;
    double end = customPlot->yAxis->range().upper;   //example values

    step->start->setCoords(begin, first);
    step->end->setCoords(begin, end);
    customPlot->replot();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72249597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档