Customizing the style of curves

ctioga2 provides an automatic styling of curves:

ctioga2 -X --math 'sin(x)' 'sin(x+1)' 'sin(x+2)' 'sin(x+3)' \
	--color-set pastel1 --yoffset 2.1 --line-style auto \
	'sin(x)' 'sin(x+1)' 'sin(x+2)' 'sin(x+3)' 

As can be seen, the first curves are displayed in various colors (red, green, blue and cyan), up to the --color-set pastel1 command, that instructs ctioga2 to use another color set, pastel1, for subsequent curves. Line style had not changed so far, but it starts to change at each curve after the --line-style auto command. As a side note, --yoffset is used here to shift the second set of curves from the first one.

Overrides

It is possible to override some of the styles either for one curve, or definitely for the following curves:

ctioga2 -X --math --line-style auto 'sin(x)' 'sin(x+1)' --line-style Solid \
	'sin(x+2)' /color Purple 'sin(x+3)' 

Commands, such as --line-style Solid override until further use of this command; using auto as a parameter lifts the overrides. Using an option, such as here /color Purple allows one to override the style element just for a single curve.

Commands handling the sets or overrides are all found within the curve style command group.

Markers

It is possible to indicate the position of data points on a curve with symbols, that are called markers in Tioga’s nomenclature:

ctioga2 -X --math /samples 31 --marker auto 'sin(x)' \
	'sin(x+1)' /marker-color Pink /marker-scale 1 \
	'sin(x+2)' /marker CircleOpen

As can be seen above, the markers symbol, size and color can be tuned using the options or the corresponding commands. The list of accepted symbol names can be found in Tioga’s documentation.

Something that comes in useful with markers is the possibility to disable lines altogether this way:

ctioga2 -X --math /samples 31 --marker auto 'sin(x)' \
	--line-style no 'sin(x+1)' /marker-color Pink \
	/marker-scale 1 'sin(x+2)' /marker CircleOpen

From ctioga2 version 0.12, it is possible to choose the marker fill and line color independently this way:

math /samples=51
marker auto
margin 0.05
marker-line-color Black
marker-line-width 0.5
plot sin(x)
plot cos(x)
plot -sin(x) /marker-fill-color=Purple

Using advanced specification of color sets, one can even draw markers with dimmed inside:

math /samples=51
marker auto
margin 0.05
marker-fill-color-set default!!20
marker-line-width 0.5
plot 'sin(x+0##4)'

The specification default!20 for marker-fill-color-set specifies that the color set for the marker fill color should be the default colorset dimmed by 100 - 20 =80% (it is a specification like LaTeX xcolor.).

Error bars

ctioga2 provides quite a bit of customizability of error bars. First of all, to have error bars, you need to specify a data column or formula specifying the errors. The simplest way to do that using the yerr= specification of the --text backend

ctioga2 -X --yrange -1.1:1.1 data.dat@'$1:$2:yerr=$2*0.2'

Here, by using yerr=$2*0.2, we force a relative error of 20% both below and above the point. Asymetric error bars can be obtained using the ymin and ymax specifications.

ctioga2 -X --yrange -1.1:1.1 --line-style no \
        --marker auto \
        data.dat@'$1:$2:ymin=$2-0.05:ymax=$2+0.2' \
        /error-bar-color=Black \
        data.dat@'$1+2:$2:xerr=$1*0.1'

It is also possible to set the color of the error bars, and to have error bars on the X values too ! Error bars tends to combine better with marker curve styles.

Path styles

When drawing curves, by default, ctioga2 joins successive points by straight lines. But there are other ways, that you select via the /path-style option or the path-style command, namely splines and impulses as of now:

math /samples=11
margin 0.03
plot x**2
plot x**2+10 /path-style=splines
plot 50-x**2 /path-style=impulses /line-width=4 /line-cap=butt

The impulses example above also demonstrates the use of the /line-cap option. By default, the end of lines are “rounded” (it’s almost never visible), but you can change that using the /line-cap option.

Filled curves

Curves in ctioga2 can be filled to a certain level using the --fill command, that takes precisely this level as an argument. See:

ctioga2 -X --math --fill axis 'sin(x)' /fill-color '#fcc'

By default, the filling has the same color as the lines of the curve, and it can be made transparent, which allows for neat effects such as:

ctioga2 -X --math --fill axis --fill-transparency 0.6 \
	'sin(x)' 'cos(x)' ' -sin(x)'

You can improve the style a bit with a difference choice of colors using one of the predefined color sets, and use a filled background:

math 
color-set pastel1
fill axis 
fill-transparency 0.6
title 'Filled trigonometry'
background Ivory
plot 'sin(x)'
plot 'cos(x)'

It is possible to show patterned fills using the /fill-pattern option:

math 
fill axis
plot 'sin(x)' /fill-pattern vlines
plot 'cos(x)' /fill-pattern hlines:3
plot '-sin(x)' /fill-pattern xlines

ctioga2 can also fill the region between two curves, but that is another story told somewhere else !

Gradients

ctioga2 provides a neat way to plot lots of curves with a linearly changing color. Behold:

ctioga2 -X --math --gradient Red Blue \
	'sin(x) + 0##12 * 0.1' 

Here, a trick needs to be explained: the 0##12 is expanded by ctioga2 into several dataset as 0, 1, 2… up until 12 (which is the reason why there are 13 curves).

The old way of making gradient in ctioga, using a gradient: dataset is still supported, but is clearly behind the new way.

More about sets

While predefined sets may suit you, it is possible to build custom sets directly on the fly:

ctioga2 -X --math  --color-set 'Red|Blue|Green' \
	--line-style-set 'Solid|Dots*3' \
	'sin(x) + 0##6 * 0.3' 

Let’s analyse in details. We have 7 curves (from 0 to 6, ie from bottom to top). The color set specification, Red|Blue|Green instructs ctioga2 to use these three colors each in turn for each curve. Now, the line style specification, Solid|Dots*3, instructs to use 3 times the Solid line style, then 3 times the Dots line style. Combining these possibilities makes for very easy play with colors/markers/line styles…

Style manipulations

ctioga2 offers advanced manipulations of style, such as skipping the next style or reusing the style of a previous curve, possibly with modifications:

math
plot sin(x) /id=sin /legend '$\sin x$'
skip
plot cos(x) /id=cos /legend '$\cos x$'
reuse-style sin
plot sin(x)**2 /legend '$\sin^2x$'
reuse-style cos
plot cos(x)**2  /line-style Dashes /legend '$\cos^2x$'

Without the call to skip, the cos(x) curve would be green (by default), but with skip, it skips to the next color (blue). The reuse-style commands reuse the style of the named curve (with the /id= option) for the next curve. The style can still be overridden by modifications.

Latest news

ctioga2 version 0.14.1 is out

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