Home

Gaston.jl

Gaston is a Julia package for plotting. It provides an interface to gnuplot, a mature and powerful plotting package available on all major platforms.

using Gaston, SpecialFunctions
x = y = 0:0.075:10;
postcomm = "set view 45,45; set pm3d lighting primary .5 specular .4"
surf(x, y, (x,y)->besselj0(y)*x^2, plotstyle="pm3d", gpcom=postcomm)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 7 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 -40 -20 0 20 40 60 80 gnuplot_plot_1 -40 -20 0 20 40 60 80

(Image inspired by What's new in gnuplot 5.2?)

Package features

Why use Gaston, when there are modern, powerful alternatives such as Plots.jl and MakiE.jl? These are some Gaston features that may be attractive to you:

Gaston's philosophy is that plotting to the screen should be fast and non-ugly. Publication-quality plots are the domain of TiKZ and pgfplots.

Knowledge of gnuplot is not required. Users familiar with gnuplot, however, will be able to take advantage of Gaston's facilities to access the (vast) feature set not directly exposed by Gaston.

Installation

Gaston supports Julia version 1.1, and requires Gnuplot version 5.0 or above (version 5.2 is recommended). To install Gaston from the Julia REPL, run

julia> ]add Gaston

Typing ] switches the Julia REPL to the package manager, and the add command installs the package. To exit the package manager, hit the backspace key.

gnuplot configuration

Gaston respects user configuration settings in gnuplot's startup file. Left un-configured, gnuplot's plots are less than attractive. The following minimum configuration is suggested (and was used to generate the plots in this document):

set linetype 1 lc rgb "blue" pt 3
set linetype 2 lc rgb "red" pt 4
set linetype 3 lc rgb "green" pt 6
set linetype 4 lc rgb "black" pt 12
set linetype 5 lc rgb "blue" pt 5
set linetype 6 lc rgb "red" pt 1
set linetype 7 lc rgb "green" pt 2
set linetype 8 lc rgb "black" pt 7
set linetype cycle 8
set style data lines
set key noautotitle
set auto fix
set offsets graph .05, graph .05, graph .05, graph .05

The configuration file is ~/.gnuplot in Unix-like systems, and %APPDATA%\GNUPLOT.INI in Windows.

Next steps

Load Gaston into your Julia session with

using Gaston

Simple plots can be generated with the plot command:

plot(1:10,title="A simple plot")

Several examples of different plotting types are given in the Examples section below.

The Settings and Configuration section includes a list of all available configuration options.

The Usage notes and FAQ section includes additional usage examples and answers frequent questions.

Running tests

Gaston includes an extensive test suite, which you can execute with:

julia> ]test Gaston

All tests should pass.

Compatibility notes

Gaston is developed in Linux, and that is where it is better supported. However, running in Julia means that it is mostly compatible with any system where Julia runs. Some known differences are listed below.

A note on Windows

Gaston runs on Windows and care is taken that all tests pass. However, currently stream communication (which Gaston relies on) is very slow in Windows; so, you can expect some plot commands to take a few seconds to complete. See this thread on Discourse for more information.

A note on OS X

Recent versions of OSX removed support for the aqua terminal from gnuplot. Before attempting to use aqua in Gaston, open a terminal and run this command:

$ gnuplot -e "set term" | grep aqua

If nothing is printed, then you do not have support for the aqua terminal and should not attempt to use it in Gaston. By default, Gaston uses the qt terminal. You can verify if your version of gnuplot supports it by issuing

gnuplot -e "set term" | grep qt

A further alternative is to revert to the x11 terminal with:

set_terminal("x11")

x11 is a fallback terminal with less bells and whistles than qt, wxt or aqua.

Support for Julia v0.6

The current version of Gaston requires Julia 1.1. The last version of Gaston that is compatible with Julia v0.6 is 0.7.4. Note that this version of Gaston is unsuppo

Bloat watch

The number of lines includes comments and empty lines.

tics = """set xtics rotate ("0.1" 1, "0.2" 2, "0.3" 3, "0.4" 4, "0.5.1" 5, "0.5.2" 6, "0.5.3" 7, "0.5.4" 8, "0.5.5" 9, "0.5.6" 10, "0.5.7" 11, "0.6" 12, "0.7" 13, "0.7.1" 14, "0.7.2" 15, "0.7.3" 16, "0.7.4" 17, "0.9.0" 18, "0.9.1" 19, "0.9.2" 20, "0.10.0" 21)"""
lc=[754,836,1196,1575,2301,2301,2343,2342,2352,2262,2262,2297,1314,1318,1362,1363,1424,1488,1382,1418,1417]
bar(lc,xlabel="Gaston version",ylabel="Lines of code",
    boxwidth="0.8 relative", linecolor="turquoise",
    title="Bloat Watch",gpcom=tics)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 7 800 1000 1200 1400 1600 1800 2000 2200 2400 0.1 0.2 0.3 0.4 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.7 0.7.1 0.7.2 0.7.3 0.7.4 0.9.0 0.9.1 0.9.2 0.10.0 Lines of code Gaston version Bloat Watch gnuplot_plot_1