美文网首页
如何使用QCustomplot绘制地震单道波形图

如何使用QCustomplot绘制地震单道波形图

作者: CodeFUN | 来源:发表于2023-02-26 22:23 被阅读0次
在地震剖面中,我们常需要绘制如下的波形图,如何使用Qt来实现呢?下面是一种尝试,可能帮你解决问题。如果你有更好的方案,欢迎评论,帮助更多人解决问题。 单道波形图
    QCustomPlot *plot = new QCustomPlot();
    customPlot->setMinimumSize(600, 400);
    // Generate datasets to plot
    QVector<double> x(1000), y(1000);
    for (int i = 0; i < 1000; ++i) {
        x[i] = i / 10.0;
        y[i] = sin(x[i]) * exp(-x[i] / 10.0) + 0.1 * (rand() / (double)RAND_MAX - 0.5);
    }

    // create and configure the graph
    QCPGraph *graph = customPlot->addGraph();
    graph->setData(x, y);
    graph->setPen(QPen(Qt::black));
    graph->setBrush(QBrush(Qt::black));

    // find the minimum and maximum y values
    double ymin = INFINITY, ymax = -INFINITY;
    for (int i=0; i<y.size(); ++i)
    {
        if (y[i] < ymin)
            ymin = y[i];
        if (y[i] > ymax)
            ymax = y[i];
    }

    // create and configure the rect item to cover the area below the x axis
    QCPItemRect *rect = new QCPItemRect(customPlot);
    rect->setBrush(QBrush(Qt::white));
    
    // set QCPItemRect only display inside of the axis
    rect->setClipToAxisRect(true);
    rect->setPen(QPen(Qt::NoPen));
    rect->topLeft->setCoords(x.first(), ymin);
    rect->bottomRight->setCoords(x.last(), 0);
    QCPGraph *graph1 = customPlot->addGraph();
    graph1->setData(x, y);
    graph1->setPen(QPen(Qt::black));
    graph1->setBrush(Qt::NoBrush);

    // set blank axis lines:
    customPlot->rescaleAxes();
    customPlot->xAxis->grid()->setVisible(false);
    customPlot->yAxis->grid()->setVisible(false);

    // make top right axes clones of bottom left axes:
    customPlot->axisRect()->setupFullAxesBox();
    // set the range and labels for the axes
    customPlot->xAxis->setRange(x.first(), x.last());
    customPlot->xAxis->setLabel("X Axis");
    customPlot->yAxis->setRange(ymin, ymax);
    customPlot->yAxis->setLabel("Y Axis");

    // show the plot
    customPlot->replot();
    customPlot->show();

相关文章

  • 在iOS中绘制录音音频波形图

    效果图 条状波形图 线状波形图 配置AvAudioSession 绘制波形图前首先需要配置好AVAudioSess...

  • 21.Qcustomplot绘制波形图--Apple的学习笔记

    一,前言 之前已经完成了小工具的一部分,主要新增的内容是Table表的使用。本次要做的是绘制波形图。 二,需求 使...

  • Qt第三库QCustomPlot—绘图一

    QCustomPlot主页展示在官网QCustomPlot用于绘制图表,和强大的Qwt一样,但功能稍逊。下载地址点...

  • Matching Django Look Advanced Co

    利用波形图 ,使用offset寻找黑位 利用波形图,使用对比度工具调整白位 利用波形图,使用offset对其能量位...

  • QCustomPlot(一):基础

    设置 QCustomPlot 使用方式: 获取最新版本的 QCustomPlot[https://www.qcus...

  • 在iOS中绘制录音音频波形图

    在开发中我遇到有根据录音来绘制波形图的需求,所以这篇文章就教大家利用swift和AVAudioSession来绘制...

  • 初学者也能画出的“美丽极光”

    解释如何绘制极光 如何绘制极光步骤1.绘制下面的天空 *说明中使用CLIP STUDIO PAINT。 使用渐变工...

  • iOS 图形绘制方案

    先说下背景,项目里需要绘制音乐和视频的波形图,由于产品上的设计,波形图的长度基本都可以达到屏幕长度的几十倍。并且图...

  • ggplot2绘制独特的分面图

    本节来介绍如何使用ggplot2自定义绘制分面并添加统计信息,以及单分面数据注释 加载R包 绘制并排箱线图 通常g...

  • SVG 绘制直线

    本节我们来学习如何在 SVG 中绘制直线,要绘制直线可以使用 元素来实现。 如何绘制直线 我们可以使用 元...

网友评论

      本文标题:如何使用QCustomplot绘制地震单道波形图

      本文链接:https://www.haomeiwen.com/subject/hrncldtx.html