当前位置:网站首页>Qcustomplot notes (I): qcustomplot adding data and curves
Qcustomplot notes (I): qcustomplot adding data and curves
2022-06-12 16:34:00 【I'm classmate Huang】
One . Preface
The landlord is studying recently QCustomplot Related content , So I want to record what I have learned , At the same time, it is also shared with those in need
The landlord is not involved in deep , It may not be right , No joy, no spray. . thank you
Two . The process
1. Drag one QWidget, Prompt for QCustomplot
2. Write code
// Data structure
QVector<double> x,y;
for(double xi=-2*M_PI;xi<2*M_PI;xi+=0.1)
{
x.push_back(xi);
y.push_back(sin(xi));
}
// Add curves , This sentence must be added , Otherwise, the curve will not be displayed
ui->widget->addGraph();
// Set up x Axis and y The name of the shaft
ui->widget->xAxis->setLabel(" This is a X Axis ");
ui->widget->yAxis->setLabel(" This is a Y Axis ");
// Set up the data
ui->widget->graph(0)->setData(x,y);
// Set curve name
ui->widget->graph(0)->setName("y=sin(x)");
// Set the display curve name
ui->widget->legend->setVisible(true);
// Set the font attribute of curve name
ui->widget->legend->setFont(QFont(" Microsoft YaHei ",13));
// Set adaption
ui->widget->rescaleAxes(true);

3. Add multiple groups of data , Adding multiple groups of data is the same as adding a single group of data , I think it's very convenient to add this ,QCustomplot The author of is really a great man
// Data structure
QVector<double> x,y;
for(double xi=-2*M_PI;xi<2*M_PI;xi+=0.1)
{
x.push_back(xi);
y.push_back(sin(xi));
}
// Add curves , This sentence must be added , Otherwise, the curve will not be displayed
ui->widget->addGraph();
// Set up x Axis and y The name of the shaft
ui->widget->xAxis->setLabel(" This is a X Axis ");
ui->widget->yAxis->setLabel(" This is a Y Axis ");
// Set up the data
ui->widget->graph(0)->setData(x,y);
// Set curve name
ui->widget->graph(0)->setName("y=sin(x)");
// Set the display curve name
ui->widget->legend->setVisible(true);
// Set the font attribute of curve name
ui->widget->legend->setFont(QFont(" Microsoft YaHei ",13));
// Set adaption
QVector<double> x1,y1;
for(double xx=-2*M_PI;xx<2*M_PI;xx+=0.1)
{
x1.push_back(xx);
y1.push_back(cos(xx));
}
//
QPen pen;
pen.setWidth(3);
pen.setColor(Qt::green);
ui->widget->addGraph();
// Set the curve color
ui->widget->graph(1)->setPen(pen);
ui->widget->graph(1)->setData(x1,y1);
ui->widget->graph(1)->setName("y=cos(x)");
ui->widget->rescaleAxes(true);
//
QPen pen3;
pen3.setWidth(3);
pen3.setColor(Qt::yellow);
ui->widget->addGraph();
QVector<double> x2,y2;
for(int i=0;i<10;i++)
{
x2.push_back(i);
y2.push_back(i);
}
ui->widget->graph(2)->setPen(pen3);
ui->widget->graph(2)->setData(x2,y2);
ui->widget->graph(2)->setName("y=x");
// When adding multiple groups of data , This sentence must be placed at the end , To realize the self adaptation of the coordinate axis
ui->widget->rescaleAxes(true);

边栏推荐
- RTOS RT thread bare metal system and multi thread system
- The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.4 随机访问(lseek)
- js監聽用戶是否打開屏幕焦點
- Sum of acwing796 submatrix
- 33-【go】Golang sync. Usage of waitgroup - ensure that the go process is completed before the main process exits
- Joint recruitment notice of ganfei research group of Wuhan University and xuzhenjiang research group of Nanchang University
- 5-5 configuring MySQL replication log point based replication
- [fishing artifact] UI library second change lowcode tool -- List part (I) design and Implementation
- 1.delete
- VIM from dislike to dependence (16) -- macro
猜你喜欢

acwing794 高精度除法

'virtue and art' in the field of recurrent+transformer video recovery

acwing 797 差分

Acwing 797 differential

Acwing788. number of reverse order pairs

Cookies and sessions

Sum of acwing796 submatrix

收藏 | 22个短视频学习Adobe Illustrator论文图形编辑和排版

The market share of packaged drinking water has been the first for eight consecutive years. How does this brand DTC continue to grow?

Project training of Shandong University rendering engine system (III)
随机推荐
use. Net upgrade assistant upgrades the net core 3.1 project to NET 6
<山东大学项目实训>渲染引擎系统(四)
Large scale real-time quantile calculation -- a brief history of quantitative sketches
【DSP视频教程】DSP视频教程第8期:DSP库三角函数,C库三角函数和硬件三角函数的性能比较,以及与Matlab的精度比较(2022-06-04)
并发包和AQS
程序的动态加载和执行
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.4 随机访问(lseek)
Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency
acwing 790. The cubic root of a number (floating-point number in half)
Servlet API
使用 .NET 升级助手将NET Core 3.1项目升级为.NET 6
Anyone who watches "Meng Hua Lu" should try this Tiktok effect
HEMA is the best representative of future retail
The C programming language (2nd Edition) notes / 7 input and output / 7.8 other functions
acwing 802. Interval sum (discretization)
'virtue and art' in the field of recurrent+transformer video recovery
Acwing high precision multiplication
Project training of Shandong University rendering engine system (III)
Glove word embedding (IMDb film review emotion prediction project practice)
收藏 | 22个短视频学习Adobe Illustrator论文图形编辑和排版