当前位置:网站首页>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);

边栏推荐
- 34- [go] golang channel knowledge points
- Project training of Shandong University rendering engine system (IV)
- generate pivot data 1
- 如何基于CCS_V11新建TMS320F28035的工程
- d的sha6转大整
- 5-5 configuring MySQL replication log point based replication
- PostgreSQL source code (53) plpgsql syntax parsing key processes and function analysis
- Interview: why do integer wrapper classes try to use equals() to compare sizes
- Glove word embedding (IMDb film review emotion prediction project practice)
- The C programming language (version 2) notes / 8 UNIX system interface / 8.7 instance (storage allocator)
猜你喜欢
![[research] reading English papers -- the welfare of researchers in English poor](/img/8a/671e6cb6a3f4e3b84ea0795dc5a365.png)
[research] reading English papers -- the welfare of researchers in English poor

acwing 803. Interval merging

超详细干货!Docker+PXC+Haproxy搭建高可用强一致性的MySQL集群

acwing 798二维差分(差分矩阵)

Acwing795 prefix sum (one dimension)

acwing 800. Target and of array elements

What's the matter with pbootcms' if judgment failure and direct display of labels?

大规模实时分位数计算——Quantile Sketches 简史

Multimix: small amount of supervision from medical images, interpretable multi task learning

MySQL interview arrangement
随机推荐
The C programming language (version 2) notes / 8 UNIX system interface / 8.7 instance (storage allocator)
Analysis of Nacos config dynamic refresh source code
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.4 随机访问(lseek)
<山东大学项目实训>渲染引擎系统(四)
33-【go】Golang sync.WaitGroup的用法—保证go协程执行完毕,主协程才退出
acwing 797 差分
Super detailed dry goods! Docker+pxc+haproxy build a MySQL Cluster with high availability and strong consistency
Exception assertion of assertj
VIM from dislike to dependence (16) -- macro
js監聽用戶是否打開屏幕焦點
calibration of sth
Thinking about the probability of drawing cards in the duel link of game king
[BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)
The C programming language (version 2) notes / 8 UNIX system interfaces / 8.6 instances (directory list)
PostgreSQL source code (53) plpgsql syntax parsing key processes and function analysis
acwing795 前缀和(一维)
[research] reading English papers -- the welfare of researchers in English poor
MySQL - server configuration related problems
Learning notes of MySQL series by database and table
34-【go】Golang channel知识点