如何在手动关闭之前保持 gnuplot-x11 图形窗口打开?

nco*_*ers 30 x11 gnuplot

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

gnuplot -e "plot \"file\" ; pause -1 \"text\""
Run Code Online (Sandbox Code Playgroud)

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

Mar*_*rco 39

使用-p--persist选项:

gnuplot --persist -e 'plot sin(x)'
Run Code Online (Sandbox Code Playgroud)

这将使窗口保持打开状态,直到手动关闭。从手册页

-p,  --persist  lets  plot  windows  survive after main gnuplot program
                exits.
Run Code Online (Sandbox Code Playgroud)

  • 由于 [zoom 不适用于 --persist](/sf/ask/2440652231/),如果您需要缩放,SDsolar 的答案会更好 (3认同)

L29*_*9Ah 14

你最好pause mouse close在脚本的末尾使用。通过这种方式,您可以使用鼠标和各种键绑定控制绘图,而无需任何额外的轮询,不像--persistreread

默认键绑定包括:

 <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
Run Code Online (Sandbox Code Playgroud)


SDs*_*lar 7

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

但是关于您的问题,它使情节保持打开状态,令人耳目一新,直到您按下 Ctrl-C

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

pause 30
reread
Run Code Online (Sandbox Code Playgroud)

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