使用gnuplot-iostream再次绘制最后一个图

时间:2018-06-04 22:44:29

标签: gnuplot gnuplot-iostream

我使用gnuplot-iostream绘制数据点。

所以,我有两套。我可以成功绘制第一组,但它在第二组失败。

             first_pts = {....};
             second_pts = {....};
             Gnuplot gp2d;
             gp2d << "set xrange [-5:5]\n";
             gp2d << "set yrange [-5:5]\n";
             for ( auto i = 0 ; i < 2 ; i ++ ) {
                 if ( i == 0 )
                   gp2d << "plot '-' with points title 'first'\n";
                   gp2d.send1d(first_pts);
                 else    
                   gp2d << "replot\n";
                   gp2d.send1d(second_pts);
                 }

我明确地不希望在一次迭代中绘制数据,因为这在我的真实环境中不起作用。重绘在这里是错误的,因此问题是 - 什么是正确的方式?

1 个答案:

答案 0 :(得分:0)

好的,我明白了。只需在gnuplot plot命令中添加另一个输入,gnuplot将在绘图前等待第二个点。

         first_pts = {....};
         second_pts = {....};
         Gnuplot gp2d;
         gp2d << "set xrange [-5:5]\n";
         gp2d << "set yrange [-5:5]\n";
         for ( auto i = 0 ; i < 2 ; i ++ ) {
             if ( i == 0 )
               gp2d << "plot '-' with points title 'first', '-' with points title 'second'\n";
               gp2d.send1d(first_pts);
             else    
               //gp2d << "replot\n";
               gp2d.send1d(second_pts);
             }