Introduction

Gnuplot is a venerable (but actively developed), very powerful and fast program for plotting. Julia is a very powerful language for numerical computing. Gaston is a package for plotting Julia data and functions using gnuplot.

The following diagram illustrates how Gaston works. On the left there is a gnuplot script; the equivalent Gaston function call is on the right.

The data to plot is in green color. In gnuplot, the data can be provided inline as a data block (as in this example), or it can be provided in a separate file. Gaston can plot data stored in arrays (x and y in this example). Gaston also supports recipes to plot arbitrary Julia types.

The lines in red specify the axes settings, affecting things like the presence of a grid, the title, the legend box, tics positions/labels, etc. Finally, in blue color, the plot settings or plotline specify the properties of one specific curve within the axes (for example, the line color, thickness and style, which marker to use, etc.)

There is a close correspondence between gnuplot and Gaston commands; in fact, the main purpose of Gaston is to translate the Julia code on the right to the gnuplot commands on the left. Gaston has two main features:

Other features are:

Note

This manual is for Gaston version 2. The manual for Gaston v1 (no longer maintained) is here.

Learning gnuplot

This documentation assumes at least a basic understanding of gnuplot. Some pointers to get started with gnuplot are:

The following are interesting plot galleries:

Installation

Gaston v2.x requires Julia version 1.8.0 or above (Gaston v1.x supports Julia 1.6 and above), and has been tested with gnuplot versions 5 and 6. You should manually install gnuplot on your system prior to using Gaston. On Linux, it is highly recommended that you select a version with Qt support: on Debian and Ubuntu, you will need gnuplot-qt. On Arch and its derivatives, a simple pacman -S gnuplot suffices.

Gnuplot also supports Windows and Mac. This author does not use these systems much, but it is said that gnuplot Windows executables are available at Sourceforge’s gnuplot repository. On Mac, gnuplot is supposed to be available using Homebrew.

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. Load Gaston into your Julia session with

using Gaston
Specifying the location of gnuplot
The location of the gnuplot executable can be specified with the environmental variable
`JULIA_GNUPLOT_EXE`. If gnuplot is in the system's path, setting this variable is not
necessary.

Support

Here are some ideas on what to do if you need help with Gaston:

Contributing

Contributions are welcome! Examples of things you can do are bug reports, improvements to the documentation, new examples and tutorials, and new features or suggestions.

Gnuplot startup file

Gnuplot reads and executes a startup file, if it exists, before every plot. Since an un-configured gnuplot produces plots that 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 ps 1.2
set linetype 2 lc rgb "red" pt 4 ps 1.2
set linetype 3 lc rgb "dark-green" pt 6 ps 1.2
set linetype 4 lc rgb "orange-red" pt 12 ps 1.2
set linetype 5 lc rgb "gold" pt 5 ps 1.2
set linetype 6 lc rgb "dark-violet" pt 1 ps 1.2
set linetype 7 lc rgb "gray50" pt 2 ps 1.2
set linetype 8 lc rgb "black" pt 7 ps 1.2
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 on Unix-like systems, and %APPDATA%\GNUPLOT.INI on Windows.

Next steps

  • Read the Tutorial.
  • See plot examples in the Examples section.
  • Learn how to extend Gaston to plot arbitrary Julia types in the Recipes section.
  • Learn all the details about how to plot with Gaston in the Manual.
  • Consult the full API Reference.

Gaston’s documentation includes three Pluto notebooks:

Acknowledgments

When developing Gaston, I’ve been inspired by the excellent features and ideas behind other Julia plotting packages, including Plots.jl, Gnuplot.jl, PGFPlotsX.jl, and Makie.jl. Many thanks to their multiple authors for freely sharing their code and their APIs!