Rongo

Jun Makino

Introduction

rongo is a simple, but potentially powerful interactive plotting program. It operates in the way similar to the good old mongo, but with subtle differences.

Here is a very simple session:

>  rongo
Entering interactive mode
 * printer test.ps/vcps
 * data testdata
 * xco  1
 * yco  2
 * lim
 * square
 * box 
 * xlabel x
 * ylabel y
 * color 2
 * con
 * quit

which creates a plot like below:

Currently, this is basically what is implemented. However, the entire power of PGPLOT is accessible from rongo. For example, to draw error bars, you can just use pgerry (or other similar functions).

Thus, if you are familiar with PGPLOT, rongo gives you a very easy and powerful way to use PGPLOT interactively. Also, since a rongo script is actually a Ruby script, you can use the whole power of Ruby to do complex operations.

License

Ruby's License

www.ruby-lang.org/ja/LICENSE.txt

www.ruby-lang.org/en/LICENSE.txt

Commands implemented so far

The following list *may be* slightly outdated. For the complete list see COMMAND_REFERENCE.

Commands with same names as in mongo (all should be in lowercase):

Note that “box” behaves quite differently than in mongo. It's similar to what is in wip.

Commands not in mongo, or with different semantics/syntax

Here is the original MONGO command list:

Installing rongo

<name>install</name>

preparation

You need NArray and Ruby/PGPLOT, which you can obtain from raa.ruby-lang.org/

NArray is at: raa.ruby-lang.org/list.rhtml?name=narray

Ruby/PGPLOT is at: raa.ruby-lang.org/list.rhtml?name=ruby-pgplot

The following is how I installed them

467  11:20   cd ../na*7
472  11:20   ruby extconf.rb
473  11:20   make
475  11:20   sudo make install

477  11:22   cd ..
479  11:22   cd rb_pgplot-0.1.2/
486  11:25   ruby extconf.rb --with-pgplot-include=/usr/local/pgplot --with-x11-dir=/usr/X11R6
487  11:25   make
488  11:25   sudo make install

As you can see, NArray is easy to install. For Ruby/PGPLOT, most likely you need to specify similar options (with appropriate values) as I used above.

Install procedure for rongo

Using rongo

rongo [input file name]

should do the job.

The sample script samples/test.rb


printer sample.gif/vgif
data testdata
xco  1
yco  2
lim
square
box 
xlabel x
ylabel y
color 2
con
quit

shows the minimal way to use rongo. Currently, only the very minimal mongo-like commands are implemented, but they are probably good enough to make basic 2D curve plots. For more advanced functions, you can just directly use Ruby or PGPLOT functions. All Ruby/PGPLOT functions can be called from rongo script.

Theory of operation

Simply put, rongo just define simple wrapper for Ruby/PGPLOT, in Rongo. As you can see in the methods list, this module defines fair number of mongo-like methods and support methods.

The rongo command load this Rongo module, and runs Rongo#rongo, which assumes the first command-line option is the script file and executes that file. If no argument is given, rongo enters to the interactive mode, in which it wait for the input from the keyboard and perform ruby “eval” function for the input line.

Before actual execution, however, it does simple editing of the file, so that it allows the user more sloppy use of commands, just it was so in mongo. The same editing is also applied to input line from keyboard.

This editing is done in convert_to_good_ruby_string, which first try to “complete” abbreviated commands. For example. “xco” is completed to “xcolumn”. Then it adds commas between each arguments.

To avoid too much problem, completion is suppressed if the first word is a single character. Thus, you can still write a simple ruby statement like

x = 1

but not

xc = 1

Well, you can write this, but it is translated to

xcolumn =, 1

which would cause error. You can still use the form

xc=1

or

xc= 1

since the completion is done for the first word with the word delimiter being whitespace or tab.

For “box”, “data”, “justification”, “label”, “printer”, “terminal”, “xlabel” and “ylabel” commands, rongo supplies double quotation marks for the arguments, if the arguments are not already quoted, so that the arguments are recognized as ruby strings.

Currently, “box” is treated differently from all other commands, in that for “box” arguments are individually quoted, while for all others all arguments are placed in one ruby string. Thus, for box, the translation is:

box BCNTSV  BCNTSV -> box "BCNTSV",  "BCNTSV"

while for label, translation is:

label Sample text ->  label "Sample text"

Single quotes may show strange results.

This is to allow the form

data datafile

instead of

data "datafile"

This is personal preference, but I like the former much more. The problem with this kind of editing is that you cannot pass normal variables or equations to these commands. However, you can work this around by using ruby's marvelous variable substitution in string literals. Thus, you can still write, for example,

filename = "datafile"
data #{outname}

Limitation

Commands I plan to implement soon

Well, practically all commands I have ever used in MONGO have been implemented, except for commands related to macros. For macros, it's much easier to use the power of Ruby itself.