3.5 gnuplot

You must have gnuplot installed to run these commands. This is an ``experimental package'' which, if it isn't installed already on your machine, can be (hopefully!) installed by typing ./sage -i gnuplot-4.0.0 on the command line in the Sage home directory.

First, here's way to plot a function:

sage: maxima.plot2d('sin(x)','[x,-5,5]') 
sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]'
sage: maxima.plot2d('sin(x)','[x,-5,5]',opts)
sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "/tmp/sin-plot.eps"]'
sage: maxima.plot2d('sin(x)','[x,-5,5]',opts)
The eps file is saved by default to the current directory but you may specify a path if you prefer.

Here is an example of a plot of a parametric curve in the plane:

sage: maxima.plot2d_parametric(["sin(t)","cos(t)"], "t",[-3.1,3.1])
sage: opts = '[gnuplot_preamble, "set nokey"], [gnuplot_term, ps],\
...   [gnuplot_out_file, "circle-plot.eps"]'
sage: maxima.plot2d_parametric(["sin(t)","cos(t)"], "t", [-3.1,3.1], options=opts)

Here is an example of a plot of a parametric surface in 3-space:

sage: maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],\
...   [-3.2,3.2],[0,3])      # optional -- pops up a window.
sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-cos-plot.eps"]'
sage: maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],\
...   [-3.2,3.2],[0,3],opts)     # optional -- pops up a window.

To illustrate how to pass gnuplot options in Sage, here is an example of a plot of a set of points involving the Riemann zeta function $ \zeta(s)$ (computed using Pari but plotted using Maxima and Gnuplot):

sage: zeta_ptsx = [ (pari(1/2 + i*I/10).zeta().real()).precision(1)\
...   for i in range (70,150)]  
sage: zeta_ptsy = [ (pari(1/2 + i*I/10).zeta().imag()).precision(1)\
...   for i in range (70,150)]  
sage: maxima.plot_list(zeta_ptsx, zeta_ptsy)  # optional -- pops up a window.
sage: opts='[gnuplot_preamble, "set nokey"], [gnuplot_term, ps],\
...   [gnuplot_out_file, "zeta.eps"]'
sage: maxima.plot_list(zeta_ptsx, zeta_ptsy, opts) # optional -- pops up a window.

See About this document... for information on suggesting changes.