bash 如何使“-persist”对 GNUPLOT 独一无二

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10196430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:03:15  来源:igfitidea点击:

How to make "-persist" unique for GNUPLOT

bashgnuplot

提问by stringparser

I'm using bash to feed gnuplot from a script. How you pop up only one window? Let say you run

我正在使用 bash 从脚本中提供 gnuplot。你怎么只弹出一个窗口?假设你跑

#!/bin/bash 
for((i=1;i<6;i++)) do
  echo "plot sin(x)"
done | gnuplot -persist

you will get 5 windows of the same plot. Is there an option to get only one?

您将获得相同图的 5 个窗口。有没有只能得到一个的选择?



There was a mistake above. That wasn't exactly the kind of run-time i'm doing. Is more like runing the next script, say, 5 times

上面有错误。那不是我正在做的那种运行时。更像是运行下一个脚本,比如 5 次

#!/bin/bash 
echo "plot sin(x)"    

I just realized that what I want to do is kill the latest gnuplot process before make the new one.

我刚刚意识到我想要做的是在创建新进程之前杀死最新的 gnuplot 进程。

Sorry for that. I'm sooo tired today :D

对不起。今天太累了 :D

回答by mgilson

the gnuplot x11 terminal uses a separate program called gnuplot_x11for displaying the results. From the help

gnuplot x11 终端使用一个单独的程序gnuplot_x11来显示结果。从帮助

The `xlib` terminal driver supports the X11 Windows System.  It generates
 gnuplot_x11 commands, but sends them to the output file specified by
 `set output '<filename>'`. `set term x11` is equivalent to
 `set output "|gnuplot_x11 -noevents"; set term xlib.`
 `xlib` takes the same set of options as `x11`.

So, if you want to kill plots that are remaining after a gnuplot -persist, it should suffice to killall gnuplot_x11.

所以,如果你想杀死在 a 之后剩余的图gnuplot -persist,它应该足够了killall gnuplot_x11

回答by byrondrossos

What about the following:

以下情况如何:

  echo `for((i=1;i<6;i++))
  do
    echo 'plot sin(x)'
  done` | gnuplot -persist

回答by jmbr

You might be interested in the iteration capabilities available in newer versions of Gnuplot (see the section Iteration in the user's guide)

您可能对较新版本的 Gnuplot 中可用的迭代功能感兴趣(请参阅用户指南中的迭代部分)

回答by user2159375

In one script one can

在一个脚本中可以

    echo "set grid" > gpfile
    tail -f  gpfile | gnuplot  '-'

then in another process one can write any gnuplot commands into the gpfile

然后在另一个进程中可以将任何 gnuplot 命令写入 gpfile

    echo "plot \"whatever\" " >> gpfile
    sleep 3
    echo "replot" >> gpfile

...etc

...等等

Its useful for realtime process control display, where some status file

它对于实时过程控制显示很有用,其中一些状态文件

is being updated at intervals.

正在不时更新。