小编Ove*_*ard的帖子

如何用c ++实时数据增加gnuplot的绘图频率?

我正在尝试使用C++实时显示传感器数据.传感器的输出高达1kHz,但gnuplot仅绘制大约10Hz的数据.

我正在使用gnuplot-iostream(http://stahlke.org/dan/gnuplot-iostream/)将数据从我的C++脚本传输到gnuplot,这很简单.但似乎绘图过程很慢,需要1/10秒来更新绘图.有没有办法增加这个频率?

编辑:这是一个简单代码的例子

#include <vector>
#include <utility>
#include <gnuplot-iostream/gnuplot-iostream.h>

typedef std::pair<double, double> Point;

int main() {
  std::vector<Point> data;

  double x = 0.0;
  double y = 0.0;
  double c = 0.0;

  Gnuplot gp;
  gp << "set terminal wxt size 800, 400\n";

  while (x < 10000) {
    x += 0.01;
    y = sin(x);
    c += 0.01;
    data.push_back(Point(x,y));
    //std::cout <<  x << std::endl;
    if (c > 0.1) {
      gp << "plot '-' with lines title 'sin(x)'\n";
      gp.send1d(data);
      c = 0.0;
    } …
Run Code Online (Sandbox Code Playgroud)

c++ iostream gnuplot real-time

0
推荐指数
1
解决办法
167
查看次数

标签 统计

c++ ×1

gnuplot ×1

iostream ×1

real-time ×1