Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Plplot integration

jtappin edited this page · 7 revisions

Scientific plotting and gtk-fortran


Under construction


Introduction.

Since Fortran is primarily a scientific programming language, it is useful to have scientific data plotting tools available to draw into a gtk window created by gtk-fortran. The plplot library can potentially provide that functionality as it has a Fortran95 binding and also support for drawing to external cairo surfaces.

For this reason the necessary tools for integrating plplot with gtk-fortran are distributed as part of the gtk-fortran tree.

Requirements and installation.

In the following it will be assumed that the cmake-based build system is being used.

For most Linux distributions, plplot is distributed as a number of packages (the precise division depends on the distribution) however for most distributions if the -dev or -devel package and the cairo drivers are selected the other required packages will be installed as well.

The cmake scripts for gtk-fortran include a search for plplot's libraries and Fortran module files. If these are found, then the interface module and the examples will be build (Unless you explicitly prevent it by adding the -D EXCLUDE_PLPLOT=Y option to cmake.

The examples and module have mainly been tested using plplot version 5.9.9, but it is possible to get them to work with 5.9.7 by uncommenting the commented-out definitions in plplot_extra.f90. Version 5.9.5 (which is the version in Ubuntu 11.10) lacks a number of features needed to use the external cairo driver effectively.

The interface module.

Correctly configuring plplot's external cairo driver requires the use of the low-level pl_cmd routine to connect the cairo context to the driver. This routine is not available to the Fortran95 binding of plplot (at least in part because it requires Fortran 2003's c-binding capabilities, and also until gtk-fortran no-one had used cairo surfaces and contexts explicitly from Fortran).

The module plplot_extra provides an interface to the pl_cmd routine and also mnemonic definitions of the command codes.

The examples

Four examples from the plplot examples page have been adapted to work within gtk-fortran, these are, included in the plplot subdirectory of gtk-fortran.

  • Example 1: Four basic x-y plots in a 2x2 layout. These are embedded in a scrolled window. (hl_plplot1e.f90)
  • Example 8: A 3-D surface plot. With controls to set the options. The window can be resized. (hl_plplot8e.f90)
  • Example 17: A constantly updating strip plot. (hl_plplot17e.f90)
  • Example 30: A demonstration of gradients and transparency. (hl_plplot30.f90)
Something went wrong with that request. Please try again.