使用八度脚本的字符模式(shell/ASCII)图 [英] Character-mode (shell/ASCII) plots with Octave scripts

查看:91
本文介绍了使用八度脚本的字符模式(shell/ASCII)图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在交互式Shell会话中运行Octave时,我知道我可以显示字符模式/ASCII图,如下所述:

When running Octave in an interactive shell session, I know I can display character-mode / ASCII plots, as discussed here: Character-mode (shell) plots with Matlab / Octave?

我的问题是,当我的八度脚本非交互运行时,我希望获得这种输出.也就是说,我希望能够运行以下内容:

My problem is that I'd like to have that kind of output when my octave script is run non-interactively. That is, I'd like to be able to run something like the following:

#!/usr/bin/octave -qf

plot(sin(0:7))

并输出如下内容:

    1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
      >      +   ---+      +      +      +      +      >
      >      +---    |                                 >
      >     |         |                                >
      >    |           |                               >
  0.5 >+  |             |                             +>
      >   |             |                            | >
      >  |               |                           | >
      > |                 |                         |  >
      >|                   +                       |   >
    0 >+                    |                     |   +>
      >                      |                    |    >
      >                      |                   |     >
      >                       |                 +      >
      >                        |               |       >
      >                         |             |        >
 -0.5 >+                        |            |        +>
      >                          |           |         >
      >                           +---      |          >
      >                               --   |           >
      >      +      +      +      +     -+|     +      >
   -1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
      1      2      3      4      5      6      7      8

如果我在ssh会话中打开八度,然后在八度终端,调用我的脚本,则会得到该输出:

I get that output if I open octave in the ssh session and then, at the octave terminal, call my script:

octave:1> testplot.m

但是我真正想做的是从其他bash脚本中调用testplot.m,例如:

But what I really want to do is to call testplot.m from other bash scripts, such as:

$ ./testplot.m

$ octave testplot.m

两者均未提供任何绘图输出.

Neither of which actually give any plot output.

我注意到交互式会话输出似乎会随着终端窗口的大小自动缩放,因此从某种意义上说,它取决于会话.

I have noticed that the interactive session output seems to scale automatically with the size of my terminal window, so in that sense it depends on the session.

感谢您的帮助!

说明-我知道如何在关闭图形可见性的情况下创建图,但是我试图避免不得不单独下载图文件.

Clarification - I know how to create plots with figure visibility turned off, but I'm trying to avoid having to separately download plot files.

我还发现了该线程:基于Unix的基于Unix的命令行制图/绘图工具,但是eplot似乎给我带来错误(可能是用户错误,数据格式错误等,但我不确定),我宁愿将其保持在八度内-已经是八度了只要我处于交互式会话中,它就能完全满足我的要求!

I also discovered this thread: Command-line Unix ASCII-based charting / plotting tool, but eplot seemed to give me errors (likely user error, bad data formatting, etc, but I don't know for sure), and I'd prefer to keep things in octave - octave already does exactly what I want as long as I'm in an interactive session!

推荐答案

您要做的就是在Octave脚本的末尾添加pause.

All you have to do is to add a pause at the end of your Octave script.

事实是,您的脚本已经在结尾处显示了情节,但是在您调用plot之后程序立即结束,因此程序退出并且您甚至都没有注意到情节.

Thing is, your script is already displaying the plot at the end but the program ends right after you you call plot, so the program exits and you don't even notice the plot.

在下面的图片中,我添加了graphics_toolkit和gnuplot终端类型的设置,不是因为您的问题需要它,而是因为在我的系统上,默认图将有所不同.

In the picture below, I added the setting of graphics_toolkit and gnuplot terminal type, not because it's needed for your problem, but because on my system the default plot would be different.

这篇关于使用八度脚本的字符模式(shell/ASCII)图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆