QCustomPlot使用之绘制散点图
2017-12-18 10:36
1831 查看
一、简单概述:QCustomPlot是基于Qt封装的一个图形绘制库、可以绘制散点图、曲线图、柱状图等各种图形,并可以把各种图形导出为png、jpg等各种格式的图片,使用很方便,只有两个文件qcustomplot.h和qcustomplot.cpp,这两个文件直接加到工程中即可。需要说明的是这个库依赖Qt中的Qt5PrintSupport模块,使用时添加上该模块即可。
二、下载地址:
QCustomPlot库下载:http://www.qcustomplot.com/index.php/download。
解压后里面有需要的说明文档、代码示例、源码等。
三、绘制散点图示例:
1、效果图示例
2、代码示例
二、下载地址:
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); }
相关文章推荐
- python使用matplotlib模块绘制多条折线图、散点图
- QT下使用QCustomPlot绘制曲线
- 使用matplotlib绘制散点图
- QT5使用QCustomPlot绘制实时曲线
- Python使用matplotlib绘制余弦的散点图示例
- QT使用QCustomPlot 绘制柱状图
- QT绘制曲线图 QCustomplot 的简单使用手册
- 使用matplotlib绘制散点图
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- Python:使用pycha快速绘制办公常用图(饼图、垂直直方图、水平直方图、散点图等七种图形)
- 使用 matplotlib 绘制western blot表达量柱状图
- 【个人收藏】qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- QCustomPlot使用手册
- 使用matplotlib绘制自定义图形
- 使用scatter与random.normal函数绘制散点图简单实例
- QCustomPlot安装使用教程
- iOS 使用 Core Plot 绘制统计图表入门
- 使用 wordcloud, jieba, PIL, matplotlib, numpy 进行分词,统计词频,并绘制词云的一次尝试
- 使用matplotlib绘制带图例的图表
- Matlab利用plot绘制正负样本散点图来分析数据