我该如何将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大字体arial大小2048,768&\ o | / usr / bin / gnuplot --persist,但随后我在终端上得到了jpeg二进制内容
答案 0 :(得分:1)
首先,选择一个窗口终端。通常,我希望默认终端(即没有显式set terminal
命令选择的终端)是窗口终端。在我的情况下,它是qt
终端,但是还有其他选项,例如set terminal x11
。您可以从gnuplot中使用set terminal
命令获取列表。第一次尝试,我只是删除set terminal dumb
命令。
第二,要保持窗口打开,我看到了两种可能性:
在调用gnuplot时添加-persist
命令行选项。
这将关闭gnuplot并完成脚本。
在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';
打印qt
。第select 'e';
行表示
没有更多数据可绘制。
使用选项1,调用gnuplot的行将为\o | /usr/bin/gnuplot -persist
。
只要要切换到文件输出,就必须添加输出文件的名称:
select 'set terminal jpeg';
select 'set output "filename.jpg"';
...
select 'plot ...