#97 external function definition

Ethan Merritt

It is not the purpose of a plotting program to provide
as many
function definitions as Mathematica et al. do. Yet,
many functions cannot be easily represented through the
pre-defined ones. Plotting an exponential integral does
not represent a major problem as a data file can be
generated by means of other software. Fitting however
is a problem. Often it is possible to define a function
through a power series or through an iterative
algorithm within gnuplot, however, this is inefficient
and cumbersome. To address this I suggest the following
features, the first of which should be easy to implement.

The user creates an executable "foo" that accepts a
number of float input parameters and outputs the value
the function takes at these parameter values. Then a
gnuplot command
f(x,y,...) = `./foo $1 $2 ...` (for foo in the current
defines the function which now can be used in fits and
Possibly a syntax more coherent with existing gnuplot
definitions can be found.

An additional enhancement would be the possibility to
define a function through interpolation of an existing
data file, possibly
with a syntax similar to the plot with line/with
(c)splines syntax. Again, the main purpose would be to
use this interpolated function within fits.


  • Ethan Merritt
    Ethan Merritt

    Logged In: YES

    Please have a look at patch #588805 "external functions via
    plugins". You will probably have to update it to apply
    against current CVS, although you could try it out by
    explicitly downloading a snapshot of the CVS tree at the
    time the patch was submitted.

    If you like the way it works, then feel free to advocate for
    its inclusion into a future gnuplot release. There was some
    favorable discussion back when the patch was first offered,
    but I do not recall any strong push by users to have it
    included. So it wasn't.

  • Logged In: YES

    The proper syntax would be a string function
    "command('blabla1')" returning the standard output as a
    string (as suggested by Petr in October 2004). I still think
    this would be a useful feature.


  • Logged In: YES

    You might also want to try #1210822. It implements the mentiond
    "command()" as "system()".

  • Ethan Merritt
    Ethan Merritt

    Logged In: YES

    The system() command is now in cvs, so I'm closing this request.
    If this method does not work for your application, please
    open a new request and explain why a different solution is

  • Ethan Merritt
    Ethan Merritt

    • assigned_to: nobody --> sfeam
    • status: open --> closed-out-of-date