|
Jun Makino
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.
Ruby’s License
www.ruby-lang.org/ja/LICENSE.txt
www.ruby-lang.org/en/LICENSE.txt
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):
PTYPE n s causes points to be drawn as n sided polygons of a style s, where s refers to: 0 = open 1 = skeletal (center connected to vertices) 2 = starred 3 = solid PTYPE will also accept one argument which is a composite = 10*n + s.
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
The argument is the same as that for PGOPEN. If no argument is given, "/xserve" is assumed
Another alias for pgopen. If no argument is given, "pgplot.ps/vcps" is assumed
This command is useful to make a square plot (which I like)
In mongo, you can use "end", but since "end" is a reserved word in Ruby we need to use something else.
used as replacement for "putlabel x" You can say
justfication center justfication left justfication right
which will affect the justification of the subsequent texts printed by label command.
change viewport, relative to the current viewport
write the command history to file filename (works only in the interactive mode)
Here is the original MONGO command list:
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.
cd rongo-xxx ruby setup.rb config ruby setup.rb setup (sudo) ruby setup.rb install
This will place the command rdoc and the library files to "default" location of setup, which are normally /usr/local/bin and /usr/local/lib/ruby/site_ruby/version-id/.
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.
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}
for i in [1..4] p i end
This is because each line is sent to ruby "eval" function. A simple way to go around this problem is to write the multi-line thing to a text file and use "load"
However, "load" bypasses the rongo line editing. So you have to write, for example,
box "BSNTSV", "BSNTSV"
instead of
box BSNTSV BSNTSV
In other words, the file to be loaded must be a valid ruby scipt.
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.