如何保持 gnuplot-x11 图形窗口打开直到手动关闭?

如何保持 gnuplot-x11 图形窗口打开直到手动关闭?

例如,这将使gnuplot-x11图形窗口保持打开状态,直到按下某个键为止:

gnuplot -e "plot \"file\" ; pause -1 \"text\""

如何保持打开状态直到手动关闭?

答案1

使用-p--persist选项:

gnuplot --persist -e 'plot sin(x)'

这将使窗口保持打开状态,直到手动关闭为止。来自手册页:

-p,  --persist  lets  plot  windows  survive after main gnuplot program
                exits.

答案2

您最好pause mouse close在脚本末尾使用。这样您就可以使用鼠标和各种按键绑定来控制绘图,而无需任何额外的轮询,这与--persist或不同reread

默认的按键绑定包括:

 <B1> doubleclick   send mouse coordinates to clipboard (pm win wxt x11)
 <B2>               annotate the graph using `mouseformat` (see keys '1', '2')
                    or draw labels if `set mouse labels is on`
 <Ctrl-B2>          remove label close to pointer if `set mouse labels` is on
 <B3>               mark zoom region (only for 2d-plots and maps)
 <B1-Motion>        change view (rotation); use <Ctrl> to rotate the axes only
 <B2-Motion>        change view (scaling); use <Ctrl> to scale the axes only
 <Shift-B2-Motion>  vertical motion -- change xyplane
 <B3-Motion>        change view (azimuth)
 <wheel-up>           scroll up (in +Y direction)
 <wheel-down>         scroll down
 <shift-wheel-up>     scroll left (in -X direction)
 <shift-wheel-down>   scroll right
 <Control-WheelUp>    zoom in on mouse position
 <Control-WheelDown>  zoom out on mouse position
 <Shift-Control-WheelUp>    pinch on x
 <Shift-Control-WheelDown>  expand on x

 q            * close this plot window

 a               `builtin-autoscale` (set autoscale keepfix; replot)
 b               `builtin-toggle-border`
 e               `builtin-replot`
 g               `builtin-toggle-grid`
 h               `builtin-help`
 i               `builtin-invert-plot-visibilities`
 l               `builtin-toggle-log` y logscale for plots, z and cb for splots
 L               `builtin-nearest-log` toggle logscale of axis nearest cursor
 m               `builtin-toggle-mouse`
 r               `builtin-toggle-ruler`
 V               `builtin-set-plots-invisible`
 v               `builtin-set-plots-visible`
 1               `builtin-previous-mouse-format`
 2               `builtin-next-mouse-format`
 5               `builtin-toggle-polardistance`
 6               `builtin-toggle-verbose`
 7               `builtin-toggle-ratio`
 n               `builtin-zoom-next` go to next zoom in the zoom stack
 p               `builtin-zoom-previous` go to previous zoom in the zoom stack
 u               `builtin-unzoom`
 +               `builtin-zoom-in` zoom in
 =               `builtin-zoom-in` zoom in
 -               `builtin-zoom-out` zoom out
 Right           `scroll right in 2d, rotate right in 3d`; <Shift> faster
 Up              `scroll up in 2d, rotate up in 3d`; <Shift> faster
 Left            `scroll left in 2d, rotate left in 3d`; <Shift> faster
 Down            `scroll down in 2d, rotate down in 3d`; <Shift> faster
 <               `rotate azimuth left in 3d`; <ctrl> faster
 >               `rotate azimuth right in 3d`; <ctrl> faster
 Escape          `builtin-cancel-zoom` cancel zoom region

答案3

您可以使绘图程序定期刷新,使其成为实时图表。这最常用于正在更新文件的数据记录器。

但就你的问题而言,它使情节保持开放,令人耳目一新,直到你按Ctrl-C

只需将这两行添加到绘图程序的末尾:

pause 30
reread

这样做的一个优点是您无需退出 gnuplot 环境即可使用它,尤其是在调试时。当您停止绘图时,您将返回到 gnuplot 提示符。您仍然可以使用!vi plotpgm.gp在 gnuplot 环境中编辑程序,然后load "plotpgm.gp使用命令再次启动它。


相关内容