Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

How to update partial data

オープン
#73 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp

調査の方向性

Start with mplot/GraphVisual.h lines 190–205, linked in the issue, and inspect how update handles the supplied x and y data. The example updates four full series on each frame, while the request is to update one sample at a time for realtime plotting. Done means identifying or enabling partial sample updates; the issue does not specify the desired API or behavior in more detail.

索引モデルが issue の本文から書いたものです。

説明

I want to plot realtime data with x range [0, 10 * 1000], 60pfs, and I found a function update, but seems it need all data to refresh, while I only want to update only one sample data at a time
https://github.com/sebsjames/mathplot/blob/edbb4cc6ca942fa54c03fe112be8fb5504eec3fa/mplot/GraphVisual.h#L190-L205

Here's the full code:

/*
 * Visualize a graph on which points are added with time.
 */
#include <iostream>
#include <fstream>
#include <cmath>
#include <array>
#include <random>

#include <sm/vec>
#include <sm/vvec>

#include <mplot/Visual.h>
#include <mplot/ColourMap.h>
#include <mplot/GraphVisual.h>

int main()
{
    int fps = 60;
    double dt = 1.0 / fps;
    int sample_rate = 1000;
    int time_window = 10;
    int total_samples = time_window * sample_rate;
    int nums_per_sample = sample_rate / 60;

    mplot::Visual v(1024, 768, "Continuous redrawing of GraphVisual");

    auto gv = std::make_unique<mplot::GraphVisual<double>> (sm::vec<float>({0,0,0}));
    gv->policy = mplot::stylepolicy::lines;
    gv->setlimits (0, total_samples, 0, 10);
    v.bindmodel (gv);

    sm::vvec<double> x;
    x.linspace (0, total_samples, total_samples);

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_real_distribution<> distrib0(0, 0.8);
    std::uniform_real_distribution<> distrib1(1, 1.8);

    std::vector<double> y1(x.size()), y2(x.size()), y3(x.size()), y4(x.size());

    gv->setdata (x, y1);
    gv->setdata (x, y2);
    gv->setdata (x, y3);
    gv->setdata (x, y4);
    gv->finalize();

    auto gvp = v.addVisualModel (gv);

    size_t idx = 0;
    while (v.readyToFinish() == false) {
        v.waitevents (dt);
        for (int i = 0; i < nums_per_sample; ++i) {
            y1[idx] = distrib0(gen);
            y2[idx] = distrib1(gen);
            y3[idx] = std::sin(idx/10.0) + 3;
            y4[idx] = std::sin(idx/50.0) + 5;
            idx++;
            idx %= total_samples;
        }
        gvp->update(x, y1, 0);
        gvp->update(x, y2, 1);
        gvp->update(x, y3, 2);
        gvp->update(x, y4, 3);
        v.render();
    }

    return 0;
}
主要言語
C++
スター
66
フォーク
13
平均マージ
12時間 42分
マージ済み PR(30日)
9

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sebsjames/mathplot のほかの issue

sebsjames/mathplot の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。