Credits Overview Plotting Styles Commands Terminals

Plugins

The set of functions available for plotting or for evaluating expressions can be extended through a plugin mechanism that imports executable functions from a shared library. For example, gnuplot versions through 5.4 did not provide a built-in implementation of the upper incomplete gamma function Q(a,x). You could define an approximation directly in gnuplot like this:

      Q(a,x) = 1. - igamma(a,x)

However this has inherently limited precision as igamma(a,x) approaches 1. If you need a more accurate implementation, it would be better to provide one via a plugin (see below). Once imported, the function can be used just as any other built-in or user-defined function in gnuplot. See import.

The gnuplot distribution includes source code and instructions for creating a plugin library in the directory demo/plugin. You can modify the simple example file demo_plugin.c by replacing one or more of the toy example functions with an implementation of the function you are interested in. This could include invocation of functions from an external mathematical library.

The demo/plugin directory also contains source for a plugin that implements Q(a,x). As noted above, this plugin allows earlier versions of gnuplot to provide the same function uigamma as version 6.

     import Q(a,x) from "uigamma_plugin"
     uigamma(a,x) = ((x<1 || x<a) ? 1.0-igamma(a,x) : Q(a,x))