QCustomPlot添加曲线、添加图例等常用功能

QCustomPlot添加曲线、添加图例等常⽤功能1、添加⼀条曲线
ui->customPlot->addGraph();
QVector<double>x(2510),y0(2510);
for(int i=0; i<2500;++i)
{
x[i]= i;
聚氨酯防滑链
y0[i]=qExp(-i/1500.0)*qCos(i/100.0);
}
ui->customPlot->graph(0)->setData(x, y0);多媒体操作系统
2、坐标轴⾃适应曲线
ui->customPlot->graph(0)->rescaleAxes();
中央空调控制
3、改变曲线的颜⾊
比重瓶法
ui->customPlot->graph(0)->setPen(QPen(Qt::red));
4、添加图例
ui->customPlot->legend->setVisible(true);
5、设置图例字体
ui->customPlot->legend->setFont(QFont("Helvetica",14));
缓冲块5、设置图例图标⼤⼩
ui->customPlot->legend->setIconSize(100,20);
6、设置曲线名
ui->customPlot->graph(0)->setName("test");
7、设置背景⾊
ui->customPlot->setBackground(QBrush(QColor(0,248,0)));
8、设置渐变背景⾊过氧化氢浓度测定
QLinearGradient gradient(0,0,0,400);
gradient.setColorAt(0,QColor(90,90,90));
gradient.setColorAt(0.38,QColor(105,105,105));
gradient.setColorAt(1,QColor(70,70,70));
ui->customPlot->setBackground(QBrush(gradient));
9、添加图的title
ui->customPlot->plotLayout()->insertRow(0);
ui->customPlot->plotLayout()->addElement(0,0,new QCPTextElement(ui->customPlot,"QCustomPlot Demo",QFont("sans",12, QFont::Bold)));
10、设置X轴和Y轴标签
ui->customPlot->xAxis->setLabel("Time");
ui->customPlot->yAxis->setLabel("Electric Current");

本文发布于:2024-09-21 17:42:35,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/2/286431.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:设置   图例   曲线
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议