plotting syntax



Hi Sheldon,

On Wed, 2007-03-21 at 06:02 -0500, sen1 at math.msu.edu wrote:
>   I would like to define a simple function to dynamically set ranges
>   with plot2d.

curiously enough, I've been working on that problem last night. I have
prepared some changes for plot2d that I should submit today.

> Consider the following
> 
> (%i17) yrange_20: [gnuplot_preamble, [ " set yrange [-20:20] " ]];
> (%o17)            [gnuplot_preamble, [ set yrange [-20:20] ]]
> (%i18) plot2d(x^2/(x+1), [x,-2,2], yrange_20);
> 
> This works fine.
> 
> Now, I would like to have 'yrange_20' as a function.
> 
> For instance,
> 
> %i19) yrange(a): [gnuplot_preamble, [ " set yrange [-a:a] " ]];
> 
> Improper value assignment:
> yrange(a) 

The changes I'm going to submit for plot2d do the following:
the [x,xmin,xmax] and [y,ymin,ymax] given to plot2d will be
passed to gnuplot or openmath (in the case of gnuplot that
means an extra command "set xrange [xmin,xmax]; set yrange
[ymin,ymax]").

That will make:
  plot2d(sin(x), [x,-%pi,2*%pi], [y,0,2])
show you a plot in the domain specified, rather than just
a plot in  0<x<%pi, 0<y<1, which is what the currently version does.
That also means that with the new version of plot2d you
will be able to use:
   a: 20;
   plot2d(x^2/(x+1), [x,-2,2], [y,-a,a]);
without having to use gnuplot_preamble.

Cheers,
Jaime