Interface to the Gnuplot interpreter

class sage.interfaces.gnuplot.Gnuplot

Bases: sage.structure.sage_object.SageObject

Interface to the Gnuplot interpreter.

plot(cmd, file=None, verbose=True, reset=True)

Draw the plot described by cmd, and possibly also save to an eps or png file.


  • cmd - string
  • file - string (default: None), if specified save plot to given file, which may be either an eps (default) or png file.
  • verbose - print some info
  • reset - True: reset gnuplot before making graph

OUTPUT: displays graph


Note that ^ s are replaced by ** s before being passed to gnuplot.

plot3d(f, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-1, zmax=1, title=None, samples=25, isosamples=20, xlabel='x', ylabel='y', interact=True)
plot3d_parametric(f='cos(u)*(3 + v*cos(u/2)), sin(u)*(3 + v*cos(u/2)), v*sin(u/2)', range1='[u=-pi:pi]', range2='[v=-0.2:0.2]', samples=50, title=None, interact=True)

Draw a parametric 3d surface and rotate it interactively.


  • f - (string) a function of two variables, e.g., ‘cos(u)*(3 + v*cos(u/2)), sin(u)*(3 + v*cos(u/2)), v*sin(u/2)’
  • range1 - (string) range of values for one variable, e.g., ‘[u=-pi:pi]’
  • range2 - (string) range of values for another variable, e.g., ‘[v=-0.2:0.2]’
  • samples - (int) number of sample points to use
  • title - (string) title of the graph.


sage: gnuplot.plot3d_parametric('v^2*sin(u), v*cos(u), v*(1-v)')   # optional - gnuplot  (not tested, since something pops up).