File formats

As of version 0.5, ctioga2 supports two file formats, a ``legacy’’, parenthese-based format and a new simpler, space-based format, that share a whole bunch of features.

Space-based format

In the new space-based format, each line starts with the command name, and contains a list of space-separated arguments. To include arguments containing spaces, you need to quote them:

math /xrange = -1:1
plot x**2
title 'Square of $x$'

Options are introduced by a /. You can put spaces around the = sign if you want, that’s optional.

You can define variables inside the file to define common arguments/options only once.


Within a ctioga2 command file, you can define and use makefile-like variables:

txt = "My title"

math /xrange = -1:1
plot x**2
title "$(txt)"

The $(txt) bit is replaced by the actual value of the variable txt, defined above. It has to be quoted as the expansion contains spaces, just like you would need to quote if you typed in directly the variable contents.

You can also use environment variables like $(HOME); this makes it easier to share plots across several computers where your user name is different, for instance.

Inline Ruby code

It is also possible to write inline Ruby code inside command files, which makes it easier to define functions to use for the math backend or for processing columns in the text backend. The inline ruby code starts with a line containing only ruby and finishes with a line containing only end ruby:

def f(x,a)
  return sin(x)*cos(a*x)
ruby end
math /samples=1000
auto-legend true
margin 0.03
plot f(x,0) 
plot f(x,1)
plot f(x,2)
plot f(x,x) /color=Purple

It is also possible to load directly a file containing Ruby code through the ruby-run command.


Old parentheses-and-comma format

Before version 0.5, only one file format was available, based on comma and parentheses. Don’t use it for new stuff, but here is how it looks

title('Square of $x$')

It is deprecated because it was found to be not flexible enough. In particular, specification of coordinates in this command files is pretty awkward and counter-intuitive.

Latest news

ctioga2 version 0.14.1 is out

Release 0.14.1 of ctioga2 fixes a crash at startup with Ruby 2.3