Plotting

ExportPlot
ExportPlot (file,type)
ExportPlot (file)

Export the contents of the plotting window to a file. The type is a string that specifies the file type to use, "png", "eps", or "ps". If the type is not specified, then it is taken to be the extension, in which case the extension must be ".png", ".eps", or ".ps".

Note that files are overwritten without asking.

On successful export, true is returned. Otherwise error is printed and exception is raised.

Examples:

genius> ExportPlot("file.png")
genius> ExportPlot("/directory/file","eps")

LinePlot
LinePlot (func1,func2,func3,...)
LinePlot (func1,func2,func3,x1,x2,y1,y2)

Plot a function (or several functions) with a line. First up to 10 arguments are functions, then optionally you can specify the limits of the plotting window as x1, x2, y1, y2. If limits are not specified, then the currently set limits apply (See LinePlotWindow)

The parameter LinePlotDrawLegends controls the drawing of the legend.

Examples:

genius> LinePlot(sin,cos)
genius> LinePlot(`(x)=x^2,-1,1,0,1)

LinePlotClear
LinePlotClear ()

Show the line plot window and clear out functions and any other lines that were drawn.

LinePlotDrawLine
LinePlotDrawLine (x1,y1,x2,y2,...)
LinePlotDrawLine (v,...)

Draw a line from x1,y1 to x2,y2. x1,y1, x2,y2 can be replaced by an n by 2 matrix for a longer polyline.

Extra parameters can be added to specify line color, thickness, arrows, and the plotting window. You can do this by adding a string "color", "thickness", "window", or "arrow", and after it either the color string, the thicknes as an integer, the window as 4-vector, and for arrow either "origin", "end", "both", or "none". For "window" we can specify "fit" rather than a vector in which case, the x range will be set precisely and the y range will be set with five percent borders around the line. Finally, the legend can be specified by adding "legend" and the string with the legend.

Examples:

genius> LinePlotDrawLine(0,0,1,1,"color","blue","thickness",3)
genius> LinePlotDrawLine([0,0;1,-1;-1,-1])
genius> LinePlotDrawLine([0,0;1,1],"arrow","end")
genius> LinePlotDrawLine(EulersMethodFull(`(x,y)=y,0,3,100),"color","blue","legend","The Solution")

LinePlotParametric
LinePlotParametric (xfunc,yfunc,...)
LinePlotParametric (xfunc,yfunc,t1,t2,tinc)
LinePlotParametric (xfunc,yfunc,t1,t2,tinc,x1,x2,y1,y2)

Plot a parametric function with a line. First come the functions for x and y then optionally the t limits as t1,t2,tinc, then optionally the limits as x1,x2,y1,y2.

If limits are not specified, then the currently set limits apply (See LinePlotWindow).

The parameter LinePlotDrawLegends controls the drawing of the legend.

LinePlotCParametric
LinePlotCParametric (func,...)
LinePlotCParametric (func,t1,t2,tinc)
LinePlotCParametric (func,t1,t2,tinc,x1,x2,y1,y2)

Plot a parametric complex valued function with a line. First comes the function that returns x+iy, then optionally the t limits as t1,t2,tinc, then optionally the limits as x1,x2,y1,y2.

If limits are not specified, then the currently set limits apply (See LinePlotWindow).

The parameter LinePlotDrawLegends controls the drawing of the legend.

SlopefieldClearSolutions
SlopefieldClearSolutions ()

Clears the solutions drawn by the SlopefieldDrawSolution function.

SlopefieldDrawSolution
SlopefieldDrawSolution (x, y, dx)

When a slope field plot is active, draw a solution with the specified initial condition. The standard Runge-Kutta method is used with increment dx. Solutions stay on the graph until a different plot is shown or until you call SlopefieldClearSolutions. You can also use the graphical interface to draw solutions and specify initial conditions with the mouse.

SlopefieldPlot
SlopefieldPlot (func)
SlopefieldPlot (func,x1,x2,y1,y2)

Plot a slope field. The function func should take two real numbers x and y, or a single complex number. Optionally you can specify the limits of the plotting window as x1, x2, y1, y2. If limits are not specified, then the currently set limits apply (See LinePlotWindow).

The parameter LinePlotDrawLegends controls the drawing of the legend.

Examples:

genius> Slopefield(`(x,y)=sin(x-y),-5,5,-5,5)

SurfacePlot
SurfacePlot (func)
SurfacePlot (func,x1,x2,y1,y2,z1,z2)
SurfacePlot (func,[x1,x2,y1,y2,z1,z2])

Plot a surface function which takes either two arguments or a complex number. First comes the function then optionally limits as x1, x2, y1, y2, z1, z2. If limits are not specified, then the currently set limits apply (See SurfacePlotWindow). Genius can only plot a single surface function at this time.

Examples:

genius> SurfacePlot(|sin|,-1,1,-1,1,0,1.5)
genius> SurfacePlot(`(x,y)=x^2+y,-1,1,-1,1,-2,2)
genius> SurfacePlot(`(z)=|z|^2,-1,1,-1,1,0,2)

SurfacePlotData
SurfacePlotData (data)
SurfacePlotData (data,label)
SurfacePlotData (data,x1,x2,y1,y2,z1,z2)
SurfacePlotData (data,label,x1,x2,y1,y2,z1,z2)
SurfacePlotData (data,[x1,x2,y1,y2,z1,z2])
SurfacePlotData (data,label,[x1,x2,y1,y2,z1,z2])

Plot a surface from data. The data is an n by 3 matrix whose rows are the x, y and z coordinates. The data can also be simply a vector whose length is a multiple of 3 and so contains the tripples of x, y, z. The data should contain at least 3 points.

Optionally we can give the label and also optionally the limits. If limits are not given, they are computed from the data, SurfacePlotWindow is not used, if you want to use it, pass it in explicitly. If label is not given then empty label is used.

Examples:

genius> SurfacePlotData([0,0,0;1,0,1;0,1,1;1,1,3])
genius> SurfacePlotData(data,"My data")
genius> SurfacePlotData(data,-1,1,-1,1,0,10)
genius> SurfacePlotData(data,SurfacePlotWindow)

Here's an example of how to plot in polar coordinates, in particular how to plot the function -r^2 * theta:

genius> d:=null; for r=0 to 1 by 0.1 do for theta=0 to 2*pi by pi/5 do d=[d;[r*cos(theta),r*sin(theta),-r^2*theta]];
genius> SurfacePlotData(d)

SurfacePlotDataGrid
SurfacePlotDataGrid (data,[x1,x2,y1,y2])
SurfacePlotDataGrid (data,[x1,x2,y1,y2,z1,z2])
SurfacePlotDataGrid (data,[x1,x2,y1,y2],label)
SurfacePlotDataGrid (data,[x1,x2,y1,y2,z1,z2],label)

Plot a surface from regular rectangular data. The data is given in a n by m matrix where the rows are the x coordinate and the columns are the y coordinate. The x coordinate is divided into equal n-1 subintervals and y coordinate is divided into equal m-1 subintervals. The limits x1 and x2 give the interval on the x-axis that we use, and the limits y1 and y2 give the interval on the y-axis that we use. If the limits z1 and z2 are not given they are computed from the data (to be the extreme values from the data).

Optionally we can give the label, if label is not given then empty label is used.

Examples:

genius> SurfacePlotDataGrid([1,2;3,4],[0,1,0,1])
genius> SurfacePlotDataGrid(data,[-1,1,-1,1],"My data")
genius> d:=null; for i=1 to 20 do for j=1 to 10 d@(i,j) = (0.1*i-1)^2-(0.1*j)^2;
genius> SurfacePlotDataGrid(d,[-1,1,0,1],"half a saddle")

VectorfieldClearSolutions
VectorfieldClearSolutions ()

Clears the solutions drawn by the VectorfieldDrawSolution function.

VectorfieldDrawSolution
VectorfieldDrawSolution (x, y, dt, tlen)

When a vector field plot is active, draw a solution with the specified initial condition. The standard Runge-Kutta method is used with increment dt for an interval of length tlen. Solutions stay on the graph until a different plot is shown or until you call VectorfieldClearSolutions. You can also use the graphical interface to draw solutions and specify initial conditions with the mouse.

VectorfieldPlot
VectorfieldPlot (funcx, funcy)
VectorfieldPlot (funcx, funcy, x1, x2, y1, y2)

Plot a two dimensional vector field. The function funcx should be the dx/dt of the vectorfield and the function funcy should be the dy/dt of the vectorfield. The functions should take two real numbers x and y, or a single complex number. When the parameter VectorfieldNormalized is true, then the magnitude of the vectors is normalized. That is, only the direction and not the magnitude is shown.

Optionally you can specify the limits of the plotting window as x1, x2, y1, y2. If limits are not specified, then the currently set limits apply (See LinePlotWindow).

The parameter LinePlotDrawLegends controls the drawing of the legend.

Examples:

genius> VectorfieldPlot(`(x,y)=x^2-y, `(x,y)=y^2-x, -1, 1, -1, 1)