• Home   /  
  • Archive by category "1"

Gnuplot Line Color Example Essay


We are happy to announce a release candidate for gnuplot version 5. Version 5 will be a major release with significant new capabilities and enhancements compared to previous gnuplot versions.

Release Notes date: 06 June 2014


  • The dot/dash pattern of a line can now be controlled independently from other properties using the keyword "dashtype".
  • The default color of individual line types can be controlled using "set linetype" (introduced in 4.6). In version 5 the overall sequence of colors can be changed using "set colors {default|classic|podo}". "set colors classic" will restore the red/green/blue/magenta/cyan/yellow sequence used by older gnuplot versions. The default and podo sequences were chosen to be more easily distinguished in print and in particular by people with color vision problems.
  • Text markup now supports bold and italic font settings in addition to the subscript, superscript, font size and other options previously provided by the "enhanced text" mode. This mode is now the default.
  • Command scripts may place in-line data in a named data block for repeated plotting.
  • Bit shift operators << and >>
  • RGB colors can include an alpha-channel for transparency. For example:

    # ARGBcolor = (Alpha << 24) + (Red << 16) + (Green << 8) + Blue

  • Secondary axes (x2, y2) can be locked to the primary axis via a mapping function. In the simplest case this guarantees that the primary and secondary axis ranges are identical. In the general case it allows you to define a non-linear axis, something that previously was only possible for the special case of log scaling.
  • The "import" command attaches a user-defined function name to a function provided by an extenal shared object (i.e. a plugin).
  • Previous commands in the history list of an interactive session can be reexecuted by number. For example "history !5" will reexecute the command numbered 5 in the list reported by "history".
  • New plot styles "with parallelaxes", labeled contours.
  • New coordinate system (Degrees, Minutes, Seconds) "set xdata geographic".
  • Hypertext labels in the interactive terminals including web display using the HTML canvas or svg terminals.

Many other additions are described in the "New Features" section of the documentation.


Gnuplot development assigns very high priority to backward compatibility with earlier versions. For example any command script that worked in version 4.0 is expected to continue to work for all version 4 releases including the most recent one (4.6.5). However changes introduced in version 5 can affect the operation of some version 4 scripts.

A brief summary of potentially incompatible changes is given here.

  • Earlier versions of gnuplot used the keyword "linetype" to mean both the color and the solid/dot/dash pattern of a line. Version 5 has separate keywords "linecolor" and "dashtype". You can use these keywords directly in a plot command or assign any desired color and a dash pattern to a linetype. The program now provides a default set of 8 linetypes, all solid. You can change these or add new linetypes as you please. You do not need to change the current terminal or terminal mode in order to use dashed lines.
  • The handling of input data containing NaN, Inf, inconsistent number of data columns, or other unexpected content has changed. See documentation under "missing" for examples and figures.
  • Time coordinates are stored internally as the number of seconds relative to the standard unix epoch 1-Jan-1970. Earlier versions of gnuplot used a different epoch internally (1-Jan-2000). This change resolves inconsistencies introduced when time in seconds was generated externally. The epoch convention used by a particular gnuplot installation can be determined using the command `print strftime("%F",0)`. Time is now stored to at least millisecond precision.
  • The "reverse" keyword (e.g. "set xrange [*:*] reverse") now affects only autoscaling. It has no effect on explicit ranges. "set xrange [0:1] reverse" is not the same as "set xrange [1:0]".
  • Options to the "fit" command are now given by "set fit ..." rather than by setting environmental variables. Fit can handle up to MAX_NUM_VAR independent variables (currently 12). Variables other than the first two (x, y) have been dissociated from axis names. E.g. "set urange [U1:U2]" has no effect on fitting. Use the command "set dummy ..." to assign names to fit variables 3 ... 12.
  • The function `timecolumn(N,"timeformat")` now has 2 parameters. Because the required second parameter is not associated with a particular data axis, this allows using the `timecolumn` function to read time data for reasons other than specifying the x or y coordinate.
  • The `call` command is implemented by providing a set of variables ARGC, ARG0, ..., ARG9. ARG0 holds the name of the script file being executed. ARG1 to ARG9 are string variables and thus may either be referenced directly or expanded as macros, e.g. @ARG1. The older convention for referencing call parameters as tokens $0 ... $9 is deprecated.
  • "unset xrange" (and other axis ranges) restores the default range.
  • "unset terminal" restores the original terminal of the current session.


Demo plots illustrating new and old features are online at http://gnuplot.sourceforge.net/demo_5.0/


  • It is tricky to build correctly functioning wxt and qt terminals under Windows.
  • Font initialization on OSX can be very slow, causing the qt terminal to issue warning or error messages for the first plot command.
  • Using mouse clicks to toggle individual plots on/off does not always work correctly for multiplots, particular if the key box is opaque. Toggling plots drawn in hidden3d mode (hidden line removal) does not work.
  • Linking against wxWidgets 3.0 is not yet supported (wxt terminal).
  • Mac OSX ships with a terminal input library that appears to be GNU libreadline, but isn't really. The program tries to cope with this, but you may get better results by configuring gnuplot to use either its own built-in readline routines or the real GNU libreadline.
  • The gnuplot build system is not very good at figuring out where to find or install LaTeX-related files. This can affect use of the new lua/tikz and ConTeXt terminals.
  • You can configure support for both wxt and qt into the same gnuplot executable, but only one of these two output modes can be used in any given gnuplot session.


Obsolete or deprecated components

The "gnuplot mode" elisp and TeX files for use with emacs are now maintained as a separate project: https://github.com/rudi/gnuplot-el so there is no longer a --with-lisp-files configuration option.

The TeX tutorial produced by --with-tutorial is horribly out of date.

./configure --enable-backwards-compatibility will allow use of [some] deprecated syntax from old gnuplot versions. However the result of using these deprecated commands may not match the old version output.

Configuration options for interactive use

The 5.0 source code supports three primary cross-platform output modes in addition to several platform-specific modes.

  1. Qt The qt terminal supports interactive display with menu-driven output to png, svg or pdf. The final 5.0 release may also support scripted output to these same file formats but this is not present in rc1. If either Qt4 or Qt5 is detected by the configure script, this will be the default terminal. It is now the fastest and most full-featured interactive terminal option. To disable this terminal:

    ./configure --without-qt To force use of Qt4 even if Qt5 is present:

    ./configure --with-qt=qt4

  2. Cairo/pango/wxWidgets This set of terminals includes
    • pngcairo, pdfcairo, epscairo, and cairolatex for output to a file
    • wxt for interactive display All of these will be built by default if the configuration script finds the required libcairo, libpango, libcairo, libwxgtk, and related support libraries To disable these terminals:

      ./configure --without-cairo ./configure --with-cairo --disable-wxt

  3. X11 (the "classic" interactive interface)

    This used to be the preferred interactive interface, but the newer wxt and qt terminals offer nicer output and a wider range of features.

Options for output to files

Of course the terminals (output modes) present in previous gnuplot versions are also still available. These include, among many more obscure options:

  • png/jpeg/gif output via libgd
  • PostScript (*.ps or *.eps)
  • Many flavors of TeX/LaTeX output, including TikZ and ConTeXt
  • Bitmapped output to support many older devices (e.g. HP deskjet, epson, seiko printers, pbm bitmapped graphics files) is available if needed but is no longer configured in by default.

    ./configure --with-bitmap-terminals

Options for generating interactive plots for web display

  • Mouseable output for display on the web can be created using either the canvas terminal (HTML5 2D canvas element) or the svg terminal. Both allow zooming, toggling plot elements on/off, and user-scriptable hot keys.



You can download a source tarball for gnuplot version 5.0.rc1 from the gnuplot development site on SourceForge.


Installation instructions are available in the source itself; the short version for linux/unix-like systems is to unpack the tarball and then build it:

cd gnuplot-5.0.rc1 ; ./configure ; make test it:

make check
install it:

make install

Pay careful attention to the output of the ./configure script. It may indicate that some output drivers have been omitted because the necessary support libraries were not found. In general you need to have previously installed the "-devel-" versions of these libraries.


Please report all bugs and installation problems to the bug tracker on SourceForge:


There is also an gnuplot discussion forum on usenet group



Gnuplot development is quite active. The development branch on SourceForge contains preliminary implementations of many new features. Following the release of gnuplot 5.0, the development branch will be identified as version 5.1. Feedback and contributions of code are very welcome.

Update: This package is no longer needed, as now supports ColorBrewer schemes out of the box. Please see the latest version of pgfplots.

Choosing what colours to use for your plotting purposes is not always straightforward. Although most programs give you reasonable defaults for doing your day-to-day plots, perhaps you’d fancy a bit more style for your plots that will be published. Indeed, I often simply use , or the native plotting routines in or for doing my first visualizations. But for publications, I often switch to , an excellent package built on top of which are implemented as packages.

The documentation for both packages is comprehensive, and in addition a lot of examples can be found online. The package already contains quite some colorbars of its own. Nevertheless, I often feel compelled to browse to ColorBrewer for its marvellous colours. For example, for some publications you need to ensure that the line colours of a plot are still discernible when printed in grayscale, which is even more relevant when you are making a density plot.

After having consulted the website regularly, I found myself constantly inserting lines such as

\definecolor{color1}{rgb}{0.215686,0.494118,0.721569} \definecolor{color2}{rgb}{0.894118,0.101961,0.109804} \definecolor{color3}{rgb}{0.301961,0.686275,0.290196}

for my plotting purposes. Of course, this works perfectly well. But once you start exploring different colour maps for your density plots, it quickly becomes tedious to change these definitions all the time. That’s why I simply downloaded the Excel sheet listing all the colour schemes, and changed them into a library. On top of that, I created also library in order to use the colours for my plotting purposes.

Using these packages now makes it straightforward to use the colorbrewer colours. Simply import the package using


and you can simply use

\begin{tikzpicture} \node[fill=Dark2-3-2, minimum size=5mm] {}; \end{tikzpicture}

An overview of all the colours (of course automatically generated) can be seen in the picture on the right. The colour schemes are named exactly the same as on the ColorBrewer website. Each individual colour of the scheme simply gets an index number, starting from 1, in addition to the letters used to designate the colour. Hence, the colour refers to the second colour of the colour schemes using colours. Alternatively, you can refer to the colour using . For more details, you might want to check out the ColorBrewer website.

It is now also easy to use the colour schemes in . Simply include the
pgf package


Then specify which colour set to use, for example using the .

\begin{tikzpicture} \begin{axis}[smooth, thick, domain=-2*pi:2*pi, cycle multi list={Set1-4}] \addplot gnuplot {tanh(x)}; \addplot gnuplot {sin(x)}; \addplot gnuplot {atan(x)}; \addplot gnuplot {tanh(-x)}; \end{axis} \end{tikzpicture}

Or you can use easily use colour maps for your fancy 3d plots

\begin{tikzpicture} \begin{axis}[domain=-2*pi:2*pi, point meta min=-1,point meta max=1, colorbar,colormap name={RdBu-11}] \addplot3[surf,shader=faceted interp,samples=50] gnuplot {sin(sqrt(x^2 + y^2))}; \end{axis} \end{tikzpicture}

You can find the files at my GitHub repository: https://github.com/vtraag/tikz-colorbrewer. Don’t forget to put the files somewhere where TikZ can find them!

Update (July 24, 2014): I added cycle lists for that use markers. It’s a shame that you cannot easily combine different lists, where you either specify the colour or the marker or the line style, because now you all have to redefine it. There should be a different that cycles through multiple lists in parallel!

One thought on “Gnuplot Line Color Example Essay

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *