various plot2d issues



Here are some issues I came across in some very simple things I tried
to do with plot2d (gnuplot version).  I will report most of them as
bugs (obviously the first one is a feature suggestion, not a bug), but
I wanted to throw them out to the list for comment.  I realize that a
lot of these bugs/misfeatures must be inherited from gnuplot, but we
should be providing a clean, usable front end to any other tools we
use, and not expose their idiosyncracies.  Of course, some would be
better fixed in the underlying plotting packages.... I am no expert in
that....

         -s

==Plotting sequences==

The following forms are currently supported by plot2d/discrete:

       plot2d([discrete,[1,2,4],[1,4,16]])
       plot2d([discrete,[[1,1],[2,4],[4,16]])

It would be handy if there were also a form that supplied an implicit
counter for the x-axis, so that

        plot2d([series,s])

would be equivalent to

        plot2d([discrete,makelist(i,i,1,length(s)),s])

Is there an option I've missed?

The obvious syntax would be [discrete,[y1,y2,...yi]], but
unfortunately that is ambiguous between [discrete,[x,y]] and
[discrete,[y1,y2]] when i=2; and those cases are possibly even useful
when combined with other plotting commands.

==UND==

plot2d is inconsistent in its treatment of UND (and other non-numeric objects).

     ff(x) := if x < 1 or x > 2 then sin(x) else 'und$

     plot2d('( f(x) ),[x,0,3] )

works fine, with a gap from 1 to 2.  But

     plot2d([discrete,makelist([i/10.0,ff(i/10.0)],i,0,30)]),

which should be roughly equivalent (with closer control of plotted
points) gives an internal error, complaining that UND is not (or
rational lisp:float).

==Y-limiting and discrete==

Limiting the Y range doesn't seem to work with Discrete, e.g.
plot2d([discrete,[0,1],[1,5],[2,1]],[y,0,3]]) ignores the [y,0,3]
part.  Though you can of course filter the points before passing them
to plot2d, and add extra points at the intercept, plot2d should be
consistent.

==Y-limiting and infinities==

When Y-limiting, plot2d *ignores* points outside the y-limits rather
than drawing the line and clipping it at the Y-limit.  Thus
plot2d(sin(x),[x,0,3],[y,0,.5]) has gaps between the plotted lines and
the top of the graph.

==Point at infinity==

plot2d doesn't understand INF.

==Missing values==

The number 1.0e308 seems to represent "missing value" for plot2d.  (I
noticed this when trying to work with infinity; see above.) This is a
very unmaximalike convention. Wouldn't it be better to use UND or
something for this?

==Evaluation context==

There is something weird going on with the way plot2d evaluates functions.

These work fine:

    plot2d('( if x<1 or x>2 then sin(x) else und), [x,0,3]);
    plot2d( lambda([x],if x<1 or x>2 then sin(x) else und), [x,0,3]);

    fff(x):=  if x<1 or x>2 then sin(x) else und;      plot2d(fff,[x,0,3]);
                 ditto
        plot2d('(fff(x)),[x,0,3]);
    fff(x):=  if x<1 or x>2 then sin(x) else 'und;      plot2d(fff,[x,0,3]);
                 ditto
        plot2d('(fff(x)),[x,0,3]);

but these are no-ops (no plot appears at all):

   plot2d('( if x<1 or x>2 then sin(x) else 'und), [x,0,3]);
   plot2d( lambda([x],if x<1 or x>2 then sin(x) else 'und), [x,0,3]);

HTHCTB as we say.  (Old MacLisp source comment = How The Hell Can This Be?)