level curves on a 3D surface
contour(x,y,z,nz,[theta,alpha,leg,flag,ebox,zlev])
contour(x,y,z,nz,<opt_args>)
:x,y two real row vectors of size n1 and n2. : :z real matrix of size (n1,n2), the values of the function or a
Scilab function which defines the surface z=f(x,y).
z= zmin + (1:nz)*(zmax-zmin)/(nz+1)
Note that the `zmin` and `zmax` levels are not drawn (generically they
are reduced to points) but they can be added with
[im,jm] = `find`_(z == zmin); // or zmax
`plot2d`_(x(im)',y(jm)',-9,"000")
: :- If `nz` is a vector, `nz(i)` gives the value of the ith level
curve. Note that it can be useful in order to see `zmin` and `zmax`
level curves to add an epsilon tolerance:
`nz=[zmin+%eps,..,zmax-%eps]`.
:
mode=0: | the level curves are drawn on the surface defined by (x,y,z). |
---|
: :mode=2: the level curves are drawn on a 2D plot. :
:
:box=0 nothing is drawn around the plot. : :box=1 unimplemented (like box=0). : :box=2 only the axes behind the surface are drawn. : :box=3 a box surrounding the surface is drawn and captions are
added.
:
:
: :zlev real number. :
contour draws level curves of a surface z=f(x,y). The level curves are drawn on a 3D surface. The optional arguments are the same as for the function plot3d (except zlev) and their meanings are the same. They control the drawing of level curves on a 3D plot. Only flag(1)=mode has a special meaning.
:mode=0 the level curves are drawn on the surface defined by (x,y,z). : :mode=1 the level curves are drawn on a 3D plot and on the plan
defined by the equation z=zlev.
: :mode=2 the level curves are drawn on a 2D plot. :
You can change the format of the floating point number printed on the levels by using xset(“fpf”,string) where string gives the format in C format syntax (for example string=”%.3f”). Use string=”“ to switch back to default format and Use string=” “ to suppress printing.
Usually we use contour2d to draw levels curves on a 2D plot.
Enter the command contour() to see a demo.
t=`linspace`_(-%pi,%pi,30);
function z=my_surface(x, y),z=x*`sin`_(x)^2*`cos`_(y),endfunction
contour(t,t,my_surface,10)
// changing the format of the printing of the levels
`xset`_("fpf","%.1f")
`clf`_()
contour(t,t,my_surface,10)
// 3D
`clf`_()
z=`feval`_(t,t,my_surface);
`plot3d`_(t,t,z);contour(t,t,z+0.2*`abs`_(z),20,flag=[0 2 4]);