如何将 gnuplot 输出替换为 PSQL 内部的图像(保持打开)输出?



如何将 gnuplot 输出替换为 PSQL 内部的图像(使其在自己的窗口中保持打开(输出?

所以我想在图形图形上输出它,以使我的用户更易读,

我的意思是,当他们启动脚本时,他们会得到一个带有图形的弹出 Xorg 窗口,直到他们关闭该窗口。

目前,我使用这种测试:

francois@zaphod:~/Documents/DEV/sh/pgsqlplot$ cat commands                                                                   
t                                                                                                                           
a                                                                                                                           
f ' '                                                                                                                       
o | /usr/bin/gnuplot                                                                                                        
select 'set title "My test Graph"; set terminal dumb 128 52; set key off; set ylabel "something"; set xlabel "temp";' || 'plot ''-'' with lines;' ;
select something from temp where date >= '2018-01-01' order by date ;                                                        
o                                                                                                                           
francois@zaphod:~/Documents/DEV/sh/pgsqlplot$ psql perso < commands

所以我猫得到一个这样的终端伪图:

3000 +-+--------------------+-----------------------+----------------------+-----------------------+--------------------+-+
+                      +                       +                      +                       +                      +
|                                                       *                                                            |
|                                                       **                                                           |
|                                                       * *                                                          |
|                                                       *  *                                                         |
|                                                       *  *                                                         |
2500 +-+                                            *       *    *                                                      +-+

[...等等...]

我在 gnuplot 和 gluplot 文档中都没有找到好的帮助页面。 你能帮我调整命令文件以在 gnuplot 和 postgres 周围使用适当的选项吗?

我尝试使用设置终端 jpeg 大字体大小 2048,768 & \o |/usr/bin/gnuplot --persist,但随后我在终端上获取 jpeg 二进制内容,然后

首先,选择一个窗口终端。通常,我希望默认终端(在没有显式set terminal命令的情况下选择的终端(是窗口终端。就我而言,它是qt终端,但还有其他选项,例如set terminal x11.您可以使用 gnuplot 中的set terminal命令获取列表。作为第一次尝试,我只会删除set terminal dumb命令。

其次,为了保持窗口打开,我看到了两种可能性:

  1. 在调用 gnuplot 时添加-persist命令行选项。

    这将关闭 gnuplot 并完成您的脚本。

  2. 在 gnuplot 脚本中使用pause mouse close命令。

    这不会关闭 gnuplot,但保留了使用鼠标和键盘快捷键进行缩放、添加网格等的可能性。

使用选项 2,我们到达此脚本(我重新排列了行以避免滚动(:

t
a
f ' ' 
o | /usr/bin/gnuplot
select 'show terminal';
select 'set title "My test Graph"';
select 'set key off';
select 'set ylabel "something"'; 
select 'set xlabel "temp"'; 
select 'plot ''-'' with lines';
select something from temp where date >= '2018-01-01' order by date ;
select 'e';
select 'pause mouse close';
o

在我的情况下,select 'show terminal';行打印qtselect 'e';行指示 没有更多的数据要绘制。

对于选项 1,调用 gnuplot 的行将o | /usr/bin/gnuplot -persist


以防万一您想切换到文件输出,您必须添加输出文件的名称:

select 'set terminal jpeg';
select 'set output "filename.jpg"';
...
select 'plot ...

最新更新