首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何从PSQL内部将gnuplot输出替换为图像(保持打开)输出?

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

Stack Overflow用户
提问于 2019-09-17 19:00:14
回答 1查看 77关注 0票数 0

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

所以我想把它输出到图形上,让我的用户更容易读懂,

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

目前,我使用这种测试:

代码语言:javascript
复制
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

所以我得到了这样的终端伪图:

代码语言:javascript
复制
  3000 +-+--------------------+-----------------------+----------------------+-----------------------+--------------------+-+
       +                      +                       +                      +                       +                      +
       |                                                       *                                                            |
       |                                                       **                                                           |
       |                                                       * *                                                          |
       |                                                       *  *                                                         |
       |                                                       *  *                                                         |
  2500 +-+                                            *       *    *                                                      +-+

...etc...

我既没有找到好的帮助页面,也没有在gnuplot中找到好的帮助页面,也没有在gluplot文档中找到好的帮助页面。你能帮我调整一下命令文件,以便在gnuket&Postgres周围使用适当的选项吗?

我尝试使用set终端jpeg大字体大小2048,768 & \o \o /usr/bin/gnuplot -持久化,但随后我在终端上获得jpeg二进制内容。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-17 20:39:51

首先,选择一个窗口终端。通常,我希望默认的终端,即在没有显式set terminal命令的情况下选择的终端是窗口终端。在我的例子中,它是qt终端,但是还有其他选项,比如set terminal x11。您可以使用set terminal命令从gnu图中获得一个列表。作为第一次尝试,我只需删除set terminal dumb命令。

第二,为了保持窗户开着,我看到了两种可能性:

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

这将关闭gnuplot并完成脚本.

  • ,使用gnuplot脚本中的pause mouse close命令。

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

使用选项2,我们得到了这个脚本(为了避免滚动,我重新安排了行):

代码语言:javascript
复制
\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

为了防止切换到文件输出,您必须添加输出文件的名称:

代码语言:javascript
复制
select 'set terminal jpeg';
select 'set output "filename.jpg"';
...
select 'plot ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57980502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档