|
From: Ethan M. <merritt@u.washington.edu> - 2005-06-15 14:43:44
|
On Wednesday 15 June 2005 06:41 am, Petr Mikulik wrote: >>> f(n)='a'.n.'.dat' >>> plot f(1), f(2) >>> NB: you cannot plot a string-valued function > But it is clear whether the function returns string or scalar. Well no, it is not clear. That is the heart of the problem. There is nothing about a user-defined function that indicates what type of value it returns. The only way to tell is to try to evaluate it, and at the point the code must choose between "plot function" and "plot data" it is not in general possible to evaluate the function at all. Part of the problem is that if the function is really a function for plotting then it has dummy variables. But at the time the plot command is parsed, dummy variables have not been assigned values and the evaluation returns an error. Another part of the problem is that gnuplot's syntax allows function definitions like: f(x) = x ? x : "NULL" which *have* no intrinsic return type. > If string, then it is filename for (s)plot, otherwise scalar function its > values to be drawn. Otherwise, would it make sense draw a curve/surface > with strings, like f(x,y)='point '.x.','.y; splot f(x,y) ? I don't > think so. I agree with that part, but I do not see a way to test what type of value is returned by a function before actually plotting it, by which time it is too late. If you can figure out how to make that test, then I support the resulting plot behavior you propose. -- Ethan A Merritt Biomolecular Structure Center University of Washington 98195-7742 |