QCustomPlot使用之绘制散点图
来源:互联网 发布:电气仿真软件下载 编辑:程序博客网 时间:2024/05/16 17:28
一、简单概述:QCustomPlot是基于Qt封装的一个图形绘制库、可以绘制散点图、曲线图、柱状图等各种图形,并可以把各种图形导出为png、jpg等各种格式的图片,使用很方便,只有两个文件qcustomplot.h和qcustomplot.cpp,这两个文件直接加到工程中即可。需要说明的是这个库依赖Qt中的Qt5PrintSupport模块,使用时添加上该模块即可。
二、下载地址:
QCustomPlot库下载:http://www.qcustomplot.com/index.php/download。
解压后里面有需要的说明文档、代码示例、源码等。
三、绘制散点图示例:
1、效果图示例
2、代码示例
CustomPoltWidget::CustomPoltWidget(QWidget *parent) : QWidget(parent){ ui.setupUi(this);// 设置坐标范围、坐标名称 QCustomPlot *pCustomPlot = new QCustomPlot(this); pCustomPlot->resize(this->width(), this->height()); pCustomPlot->xAxis->setRange(-180.00, 180.00); pCustomPlot->yAxis->setRange(-90.00, 90.00); pCustomPlot->xAxis->setLabel("latitude"); pCustomPlot->yAxis->setLabel("longitude");// 增加图层 pCustomPlot->addGraph(pCustomPlot->yAxis, pCustomPlot->xAxis); QVector<double> latVector, lonVector; latVector << -75 << -50 << -50 << 0 << 50 << 100 << 75; lonVector << -75 << -50 << -25 << 0 << 25 << 50 << 75;// 设置画笔风格 QPen drawPen; drawPen.setColor(Qt::red); drawPen.setWidth(4);// 绘制散点 QCPGraph * curGraph = pCustomPlot->addGraph(); curGraph->setPen(drawPen); curGraph->setLineStyle(QCPGraph::lsNone); curGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2)); curGraph->setData(latVector, lonVector); pCustomPlot->xAxis->setVisible(true); pCustomPlot->yAxis->setVisible(true);// 保存为png图片 QString path = QApplication::applicationDirPath() + "\\" + "test123.png"; pCustomPlot->savePng(path);}
阅读全文
0 0
- QCustomPlot使用之绘制散点图
- QT使用QCustomPlot 绘制柱状图
- Qt之QCustomPlot绘制随机散布点
- QCustomPlot 使用——绘制折线图
- QT5使用QCustomPlot绘制实时曲线
- QT利用QCustomPlot绘制曲线图
- qt绘制坐标系--利用QCustomPlot
- QCustomPlot之Items
- QCustomPlot之QTextDocument
- QCustomPlot之用户交互
- QCustomPlot之数据结构
- QCustomPlot之性能提升
- QCustomPlot之布局系统
- QCustomPlot之布局系统
- QCustomPlot之布局系统
- Qt之QCustomPlot范例
- QCustomPlot安装使用教程
- QCustomPlot的基本使用
- Stanford coursera Andrew Ng 机器学习课程编程作业(Exercise 2)Python3.x
- BASIC-13数列排序
- 一个查表法的程序以及思路。
- java 代码笔记 求平均值
- Hibernate中实体对象生命周期及状态
- QCustomPlot使用之绘制散点图
- QTableWidget详解(样式、右键菜单、表头塌陷、多选等)
- layUI表单提交时,控制台出现$(...)serializeObject is not a function错误——解决方案
- 二叉排序树之查找算法
- PyAutoGUI-python版的autoit/AHK
- 在python 3.6 x64中安装opencv3
- windows 下启动zookeeper的zkServer.cmd服务闪退
- nginx防止图片被盗用
- java io流,读取文件内容