QCustomPlot的简单使用
2016-08-12 13:29
519 查看
简单的图标绘制可以用QCustomPlot 就一个cpp和一个.h文件包含
其他的还有QT自身的QChart,不过要QT5.X以后的版本
下载QCustomPlot http://qcustomplot.com/index.php
最主要的类是 QCustomPlot,这是一个widget。所有的画图都是基于这个widget.
按照文章中基础的来写一个。
QCustomPlot customPlot() ;
customPlot.resize(600,400);
// generate some data:
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=50; i<80; ++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
}
// 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");
// set axes ranges, so we see all data:
customPlot.xAxis->setRange(-1, 1);
customPlot.yAxis->setRange(0, 1);
customPlot.replot();
customPlot.show();
实现了y=x^2的画图
其他的还有QT自身的QChart,不过要QT5.X以后的版本
下载QCustomPlot http://qcustomplot.com/index.php
最主要的类是 QCustomPlot,这是一个widget。所有的画图都是基于这个widget.
按照文章中基础的来写一个。
QCustomPlot customPlot() ;
customPlot.resize(600,400);
// generate some data:
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=50; i<80; ++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
}
// 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");
// set axes ranges, so we see all data:
customPlot.xAxis->setRange(-1, 1);
customPlot.yAxis->setRange(0, 1);
customPlot.replot();
customPlot.show();
实现了y=x^2的画图
相关文章推荐
- QT绘制曲线图 QCustomplot 的简单使用手册
- Matplotlib简介和pyplot的简单使用——文本标注和箭头
- Matplotlib简介和pyplot的简单使用——Artists
- QCustomPlot绘图控件的使用
- QCustomPlot使用手册(四)
- QCustomPlot使用手册(三)
- QCustomPlot使用手册(二)
- Matplotlib简介和pyplot的简单使用
- Qt绘图插件QCustomPlot配置、使用
- [转] QT超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- QT使用QCustomPlot 绘制柱状图
- Matplotlib简介和pyplot的简单使用——直方统计图和轮廓曲线
- QCustomPlot的使用 - 1安装
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- Matplotlib简介和pyplot的简单使用——局部放大图
- core-plot——简单使用(续)
- QCustomPlot安装使用教程
- QCustomPlot使用手册(一)
- 转:qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程