我如何从PSQL内部将gnuplot输出替换为图像(在自己的窗口中保持打开)输出?
所以我想把它输出到图形上,让我的用户更容易读懂,
我的意思是,当他们启动脚本时,他们会得到一个弹出的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 +-+ * * * +-+...etc...
我既没有找到好的帮助页面,也没有在gnuplot中找到好的帮助页面,也没有在gluplot文档中找到好的帮助页面。你能帮我调整一下命令文件,以便在gnuket&Postgres周围使用适当的选项吗?
我尝试使用set终端jpeg大字体大小2048,768 & \o \o /usr/bin/gnuplot -持久化,但随后我在终端上获得jpeg二进制内容。
发布于 2019-09-17 20:39:51
首先,选择一个窗口终端。通常,我希望默认的终端,即在没有显式set terminal命令的情况下选择的终端是窗口终端。在我的例子中,它是qt终端,但是还有其他选项,比如set terminal x11。您可以使用set terminal命令从gnu图中获得一个列表。作为第一次尝试,我只需删除set terminal dumb命令。
第二,为了保持窗户开着,我看到了两种可能性:
-persist命令行选项。这将关闭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 ...https://stackoverflow.com/questions/57980502
复制相似问题