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 do not provide a built-in implementation of the upper incomplete gamma function Q(a,x). Q(a, x) = [IMAGE svg][IMAGE svg]ta-1e-tdt .You could define an approximation directly in gnuplot like this:
Q(a,x) = 1. - igamma(a,x)However this has inherently limited precision as the value of Q 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 the current development version.
import Q(a,x) from "uigamma_plugin" uigamma(a,x) = ((x<1 || x<a) ? 1.0-igamma(a,x) : Q(a,x))
Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
Distributed under the gnuplot license (rights to distribute modified versions are withheld).