当前位置: 首页 > wzjs >正文

个人网站制作基本步骤输入关键词进行搜索

个人网站制作基本步骤,输入关键词进行搜索,python微信小程序开发教程,网页设计与网站建设案例课堂本文详细介绍了qcustomplot绘制曲线图的流程,一段代码一段代码运行看效果。通过阅读本文,读者可以了解到每一项怎么用代码进行配置,进而实现自己想要的图表效果。(本文只针对曲线图) 1 最简单的图形(入门&…

本文详细介绍了qcustomplot绘制曲线图的流程,一段代码一段代码运行看效果。通过阅读本文,读者可以了解到每一项怎么用代码进行配置,进而实现自己想要的图表效果。(本文只针对曲线图)

1 最简单的图形(入门)

  • 头文件
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include "qcustomplot.h"
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();public:void paintLine(QCustomPlot *customPlot);private:Ui::Widget *ui;
};
#endif // WIDGET_H
  • 源文件
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);paintLine(ui->lineWidget);}Widget::~Widget()
{delete ui;
}void Widget::paintLine(QCustomPlot *customPlot)
{QVector<double> x(101), y(101);for (int i = 0; i < x.size(); i++){x[i] = i / 50.0 - 1;    // x从-1 到 1y[i] = x[i] * x[i];   // 二次函数}customPlot->addGraph();    // 添加一幅折线图customPlot->graph(0)->setData(x, y);    // 为曲线图添加数据 注意这个方法只能是double类型 库内就是这样声明与定义的customPlot->graph(0)->setName("y=x^{2}");// 设置x与y坐标轴的范围customPlot->xAxis->setRange(-1, 1);customPlot->yAxis->setRange(0, 1);// 设置x与y坐标轴的标签customPlot->xAxis->setLabel("x");customPlot->yAxis->setLabel("y");// 显示图例customPlot->legend->setVisible(true);
}
  • 运行效果

在这里插入图片描述

2 美化一下

美化之前,先有几个名词声明一下

  • 轴线
  • 轴刻度线(长的刻度线)
  • 轴子刻度线(短的刻度线)
  • 轴刻度值
  • 轴标签

2.1 设置背景颜色、轴、刻度线、刻度值、刻度标签

    QLinearGradient plotGradient;plotGradient.setStart(0, 0);plotGradient.setFinalStop(0, 350);plotGradient.setColorAt(0, QColor(80, 80, 80));plotGradient.setColorAt(1, QColor(50, 50, 50));customPlot->setBackground(plotGradient);      // 设置背景颜色

在这里插入图片描述

customPlot->axisRect()->setBackground(Qt::red);

在这里插入图片描述

// 设置轴风格customPlot->xAxis->setBasePen(QPen(Qt::white, 1));

在这里插入图片描述

customPlot->xAxis->setTickPen(QPen(Qt::white, 1));    // 轴刻度线和画笔

在这里插入图片描述

注意这两张图像的区别,非常微小的区别

上边这张是设置轴,下边这张是设置轴刻度

customPlot->xAxis->setSubTickPen(QPen(Qt::white, 1));  // 轴子刻度线的画笔

在这里插入图片描述
发现区别了吗?发现具体配置的效果显示在哪了吗?如果没有发现,请仔细对比。

customPlot->xAxis->setTickLabelColor(Qt::white);  // 设置轴刻度颜色

在这里插入图片描述

    customPlot->xAxis->setLabel("标签");                  // 只有设置了标签,轴标签颜色才会显示customPlot->xAxis->setLabelColor(Qt::white);          // 设置轴标签颜色

在这里插入图片描述

    customPlot->xAxis->setTickLengthIn(133);   // 为了效果明显 将值设置的大一点,原来是这个效果 轴线内刻度的长度

在这里插入图片描述

customPlot->xAxis->setTickLengthOut(125);    // 为了效果明显 将值设置的大一点,原来是这个效果 轴线外刻度的长度

在这里插入图片描述

customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow); // 设置轴结束的箭头

在这里插入图片描述

	// 设置网格的风格customPlot->xAxis->grid()->setPen(QPen(Qt::red, 1, Qt::DotLine));

在这里插入图片描述

    // 设置水平线customPlot->yAxis->grid()->setPen(QPen(Qt::yellow, 1, Qt::DotLine));

在这里插入图片描述

    // 设置子刻度线customPlot->xAxis->grid()->setSubGridVisible(true);customPlot->xAxis->grid()->setSubGridPen(QPen(Qt::blue, 1, Qt::DotLine));

在这里插入图片描述

 	customPlot->yAxis->grid()->setSubGridVisible(true);customPlot->yAxis->grid()->setSubGridPen(QPen(Qt::green, 1, Qt::DashLine));

在这里插入图片描述

    // 设置刻度为0时的网格线的画笔customPlot->xAxis->grid()->setZeroLinePen(QPen(Qt::red, 3));customPlot->yAxis->grid()->setZeroLinePen(QPen(Qt::red));

在这里插入图片描述

至此,有关图像轴的设置就介绍完了

2.2 线型

利用官网的例子进行介绍

    // 图表的风格QPen pen;// 存放曲线的风格名称QStringList lineNames;lineNames << "lsNone" << "lsLine" << "lsStepLeft" << "lsStepRight" << "lsStrepCenter" << "lsImpulse";for(int i = 0; i < lineNames.size(); i++){customPlot->addGraph();pen.setColor(QColor(qSin(i * 1 + 1.2) * 80 + 80, qSin(i * 0.3) * 80 + 80, qSin(i * 0.3 + 1.5) * 80 + 80));customPlot->graph()->setPen(pen);customPlot->graph()->setName(lineNames.at(i));customPlot->graph()->setLineStyle((QCPGraph::LineStyle)i);customPlot->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 6));QVector<double> x(15), y(15);for (int j = 0; j < x.size(); j++){x[j] = j / 15.0 * 5 * 3.14 + 0.01;y[j] = 7 * qSin(x[j]) / x[j]  - (i - QCPGraph::lsNone) * 5 + (QCPGraph::lsImpulse) * 5 + 2;}customPlot->graph()->setData(x, y);customPlot->graph()->rescaleAxes(true);}

在这里插入图片描述

本文参考:

https://blog.csdn.net/qq10097355/article/details/104845706https://www.qcustomplot.com/  官网
http://www.dtcms.com/wzjs/369960.html

相关文章:

  • 中小企业网站建设 网络营销网站建设情况
  • 西安市免费做网站提高工作效率8个方法
  • 做网站的后台开发需要会些什么淘宝怎么做引流和推广
  • 临沂教育平台网站建设搜索引擎营销简称为
  • 个人怎么做影视网站最近三天的新闻大事摘抄
  • 广告接单平台app铜陵seo
  • 京东网的公司全称是南宁网站seo
  • 网站 备案地优化seo公司哪家好
  • java网站开发的底层语言是福建seo优化
  • 做外贸生意上哪个网站google推广seo
  • 搭建网站的主要风险网站推广公司大家好
  • 免费公司介绍网站怎么做河南郑州最新事件
  • 珠海网站制作报价seo兼职接单平台
  • 网站建设的方案计划seo关键词排名优化销售
  • 凡科做的网站打不开百度一下生活更好
  • 网站基础建设网络营销网站推广
  • 四川省城乡住房建设部网站首页免费发布活动的平台
  • 做企业营销网站google海外推广
  • 外贸网站制作广州推广网站最有效办法
  • 什么网站可以做兼职设计企业内训
  • 湖南网站seo地址福州seo招聘
  • 宁波市铁路建设指挥部网站网络优化app
  • 用html做登录网站网络搜索引擎优化
  • 邵阳疫情最新消息情况seo优化工具大全
  • WordPress手机主题冲突津seo快速排名
  • 网站模板 div百度指数官网数据
  • 太原百度网站快速排名关键词权重如何打造
  • 深圳做针织衫服装的网站网络优化工程师证书
  • 宁津华企动力做网站的电话多少推广app赚钱
  • h5开发网站优点北京网站制作