3D plot of a surface (2025)

Arguments

x,y

row vectors of sizes n1 and n2 (x-axis and y-axis coordinates). These coordinates must be monotone.

z

matrix of size (n1,n2). z(i,j) is the value of the surface at the point (x(i),y(j)).

xf,yf,zf

matrices of size (nf,n). They define the facets used to draw the surface. There are n facets. Each facet i is defined by a polygon with nf points. The x-axis, y-axis and z-axis coordinates of the points of the ith facet are given respectively by xf(:,i), yf(:,i) and zf(:,i).

colors

a vector of size n giving the color of each facets or a matrix of size (nf,n) giving color near each facet boundary (facet color is interpolated ).

<opt_args>

This represents a sequence of statements key1=value1, key2=value2 ,... where key1, key2,... can be one of the following: theta, alpha ,leg,flag,ebox (see definition below).

theta, alpha

real values giving in degree the spherical coordinates of the observation point (by default, alpha=35° and theta=45°).

leg

string defining the labels for each axis with @ as a field separator, for example "X@Y@Z" (by default, axis have no label).

flag

a real vector of size three. flag=[mode,type,box](by default flag=[2,8,4]).

mode

an integer (surface color).

mode>0

the surface is painted with color "mode" ; the boundary of the facet is drawn with current line style and color.

mode=0:

a mesh of the surface is drawn.

mode<0:

the surface is painted with color "-mode" ; the boundary of the facet is not drawn.

Note that the surface color treatment can be done using color_mode and color_flag options through the surface entity properties (see surface_properties).

type

an integer (scaling).

type=0:

the plot is made using the current 3D scaling (set by a previous call to param3d, plot3d, contour or plot3d1).

type=1:

rescales automatically 3d boxes with extreme aspect ratios, the boundaries are specified by the value of the optional argument ebox.

type=2:

rescales automatically 3d boxes with extreme aspect ratios, the boundaries are computed using the given data.

type=3:

3d isometric with box bounds given by optional ebox, similarly to type=1.

type=4:

3d isometric bounds derived from the data, similarly to type=2.

type=5:

3d expanded isometric bounds with box bounds given by optional ebox, similarly to type=1.

type=6:

3d expanded isometric bounds derived from the data, similarly to type=2.

Note that axes boundaries can be customized through the axes entity properties (see axes_properties).

box

an integer (frame around the 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.

box=4:

a box surrounding the surface is drawn, captions and axes are added.

Note that axes aspect can also be customized through the axes entity properties (see axes_properties).

ebox

It specifies the boundaries of the plot as the vector [xmin,xmax,ymin,ymax,zmin,zmax]. This argument is used together with type in flag : if it is set to 1, 3 or 5 (see above to see the corresponding behaviour). If flag is missing, ebox is not taken into account (by default ebox is missing).

Note that, when specified, the ebox argument acts on the data_bounds field that can also be reset through the axes entity properties (see axes_properties).

Description

plot3d(z) draws the parametric surface z=f(x,y) where x=1:m, y=1:n and [m,n]=size(z) where m and n must be greater than 1.

plot3d(x,y,z,[theta,alpha,leg,flag,ebox]) draws the parametric surface z=f(x,y).

plot3d(xf,yf,zf,[theta,alpha,leg ,flag,ebox]) draws a surface defined by a set of facets. You can draw multiple plots by replacing xf, yf and zf by multiple matrices assembled by rows as [xf1 xf2 ...], [yf1 yf2 ...] and [zf1 zf2 ...]. Note that data can also be set or get through the surface entity properties (see surface_properties).

You can give a specific color for each facet by using list(zf,colors) instead of zf, where colors is a vector of size n. If colors(i) is positive it gives the color of facet i and the boundary of the facet is drawn with current line style and color. If colors(i) is negative, color id -colors(i) is used and the boundary of the facet is not drawn.

It is also possible to get interpolated color for facets. For that the color argument must be a matrix of size nfxn giving the color near each boundary of each facets. In this case positive values for colors mean that the boundary are not drawn. Note that colors can also be set through the surface entity properties (via tlist affectations) and edited using color_flag option (see surface_properties).

The optional arguments theta, alpha, leg ,flag, ebox ,can be passed by a sequence of statements key1=value1, key2=value2, ... In this case, the order has no special meaning. Note that all these optional arguments except flag can be customized through the axes entity properties (see axes_properties). As described before, the flag option deals with surface entity properties for mode (see surface_properties) and axes properties for type and box (see axes_properties).

You can use the function genfac3d to compute four sided facets from the surface z=f(x,y). eval3dp can also be used.

Enter the command plot3d() to see a demo.

Examples

// simple plot using z=f(x,y)t=[0:0.3:2*%pi]';z=sin(t)*cos(t');plot3d(t,t,z)

3D plot of a surface (1)

t=[0:0.3:2*%pi]';z=sin(t)*cos(t');// same plot using facets computed by genfac3d[xx,yy,zz]=genfac3d(t,t,z);plot3d(xx,yy,zz)

3D plot of a surface (2)

// multiple plotst=[0:0.3:2*%pi]';z=sin(t)*cos(t');// same plot using facets computed by genfac3d[xx,yy,zz]=genfac3d(t,t,z);plot3d([xx xx],[yy yy],[zz 4+zz])

3D plot of a surface (3)

// multiple plots using colorst=[0:0.3:2*%pi]';z=sin(t)*cos(t');// same plot using facets computed by genfac3d[xx,yy,zz]=genfac3d(t,t,z);plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))

3D plot of a surface (4)

// simple plot with viewpoint and captionsplot3d(1:10,1:20,10*rand(10,20),alpha=35,theta=45,flag=[2,2,3])

3D plot of a surface (5)

// plot of a sphere using facets computed by eval3dpdeff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)";.. "y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)";.. "z=r*sin(alp)+orig(3)*ones(tet)"]);r=1; orig=[0 0 0];[xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));clf();plot3d(xx,yy,zz)

3D plot of a surface (6)

f=gcf();f.color_map = hot(128);r=0.3;orig=[1.5 0 0];deff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)";.. "y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)";.. "z=r*sin(alp)+orig(3)*ones(tet)"]);[xx,yy,zz]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));[xx1,yy1,zz1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));cc=(xx+zz+2)*32;cc1=(xx1-orig(1)+zz1/r+2)*32;clf();plot3d1([xx xx1],[yy yy1],list([zz,zz1],[cc cc1]),theta=70,alpha=80,flag=[5,6,3])

3D plot of a surface (7)

t=[0:0.3:2*%pi]'; z=sin(t)*cos(t');[xx,yy,zz]=genfac3d(t,t,z);plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))e=gce();f=e.data;TL = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,6*rand(f.z)); // random color matrixe.data = TL;TL2 = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,4*rand(1,800)); // random color vectore.data = TL2;TL3 = tlist(["3d" "x" "y" "z" "color"],f.x,f.y,f.z,[20*ones(1,400) 6*ones(1,400)]);e.data = TL3;TL4 = tlist(["3d" "x" "y" "z"],f.x,f.y,f.z); // no colore.data = TL4;e.color_flag=1 // color index proportional to altitude (z coord.)e.color_flag=2; // back to default modee.color_flag= 3; // interpolated shading mode (based on blue default color)clf()plot3d([xx xx],[yy yy],list([zz zz+4],[4*ones(1,400) 5*ones(1,400)]))h=gce(); //get handle on current entity (here the surface)a=gca(); //get current axesa.rotation_angles=[40,70];a.grid=[1 1 1]; //make gridsa.data_bounds=[-6,0,-1;6,6,5];a.axes_visible="off"; //axes are hiddena.axes_bounds=[.2 0 1 1];h.color_flag=1; //color according to zh.color_mode=-2; //remove the facets boundary by setting color_mode to white colorh.color_flag=2; //color according to given colorsh.color_mode = -1; // put the facets boundary back by setting color_mode to black colorf=gcf();//get the handle of the parent figuref.color_map=hot(512);c=[1:400,1:400];TL.color = [c;c+1;c+2;c+3];h.data = TL;h.color_flag=3; // interpolated shading mode

3D plot of a surface (8)

We can use the plot3d function to plot a set of patches (triangular, quadrangular, etc).

// The plot3d function to draw patches:// patch(x,y,[z])// patch(x,y,[list(z,c)])// The size of x : number of points in the patches x number of patches// y and z have the same sizes as x// c:// - a vector of size number of patches: the color of the patches// - a matrix of size number of points in the patches x number of// patches: the color of each points of each patches// Example 1: a set of triangular patchesx = [0 0; 0 1; 1 1];y = [1 1; 2 2; 2 1];z = [1 1; 1 1; 1 1];tcolor = [2 3]';subplot(2,2,1);plot3d(x,y,list(z,tcolor));xtitle('A triangle set of patches');// Example 2: a mixture of triangular and quadrangular patchesxquad = [5, 0; 10,0; 15,5; 10,5];yquad = [15,0; 20,10; 15,15; 10,5];zquad = ones(4,2);xtri = [ 0,10,10, 5, 0; 10,20,20, 5, 0; 20,20,15,10,10];ytri = [ 0,10,20, 5,10; 10,20,20,15,20; 0, 0,15,10,20];ztri = zeros(3,5);subplot(2,2,3);plot3d(xquad,yquad,zquad);plot3d(xtri,ytri,ztri);xtitle('Mixing triangle and quadrangle set of patches');// Example 3: some rabbitsrabxtri = [ 5, 5, 2.5, 7.5, 10; 5, 15, 5, 10, 10; 15, 15, 5, 10, 15];rabytri = [10, 10, 9.5, 2.5, 0; 20, 10, 12, 5, 5; 10 0 7 0 0];rabztri = [0,0,0,0,0; 0,0,0,0,0; 0,0,0,0,0];rabtricolor_byface = [2 2 2 2 2];rabtricolor = [2,2,2,2,2; 3,3,3,3,3; 4,4,4,4,4];rabxquad = [0, 1; 0, 6; 5,11; 5, 6];rabyquad = [18,23; 23,28; 23,28; 18,23];rabzquad = [1,1; 1,1; 1,1; 1,1];rabquadcolor_byface = [2 2];rabquadcolor = [2,2; 3,3; 4,4; 5,5];subplot(2,2,2);plot3d(rabxtri, rabytri, list(rabztri,rabtricolor));plot3d(rabxquad,rabyquad,list(rabzquad,rabquadcolor));h = gcf();h.children(1).background = 1;xtitle('A psychedelic rabbit set of patches');subplot(2,2,4);plot3d(rabxtri, rabytri, list(rabztri,rabtricolor_byface));plot3d(rabxquad,rabyquad,list(rabzquad,rabquadcolor_byface));h = gcf();h.children(1).background = 1;xtitle('A standard rabbit set of patches');

3D plot of a surface (9)

We can also use the plot3d function to plot a set of patches using vertex and faces.

// Vertex / Faces example: 3D example// The vertex list contains the list of unique points composing each patch// The points common to 2 patches are not repeated in the vertex listvertex = [0 1 1; 0 2 2; 1 2 3; 1 1 4];// The face list indicates which points are composing the patch.face = [1 2 3; 1 3 4];tcolor = [2 3]';// The formula used to translate the vertex / face representation into x, y, z listsxvf = matrix(vertex(face,1),size(face,1),length(vertex(face,1))/size(face,1))';yvf = matrix(vertex(face,2),size(face,1),length(vertex(face,1))/size(face,1))';zvf = matrix(vertex(face,3),size(face,1),length(vertex(face,1))/size(face,1))';scf();subplot(2,1,1);plot3d(xvf,yvf,list(zvf,tcolor));xtitle('A triangle set of patches - vertex / face mode - 3d');// 2D test// We use the 3D representation with a 0 Z values and then switch to 2D representation// Vertex / Faces example: 3D example// The vertex list contains the list of unique points composing each patch// The points common to 2 patches are not repeated in the vertex listvertex = [0 1; 0 2; 1 2; 1 1];// The face list indicates which points are composing the patch.face = [1 2 3; 1 3 4];// The formula used to translate the vertex / face representation into x, y, z listsxvf = matrix(vertex(face,1),size(face,1),length(vertex(face,1))/size(face,1))';yvf = matrix(vertex(face,2),size(face,1),length(vertex(face,1))/size(face,1))';zvf = matrix(zeros(vertex(face,2)),size(face,1),length(vertex(face,1))/size(face,1))';tcolor = [2 3]';subplot(2,1,2);plot3d(xvf,yvf,list(zvf,tcolor));xtitle('A triangle set of patches - vertex / face mode - 2D');a = gca();a.view = '2d';

3D plot of a surface (10)

How to set manually some ticks

plot3d();h = gca();h.x_ticks = tlist(['ticks','locations','labels'],[-2,-1,0,1,2],['-2','-1','0','1','2']);h.y_ticks = tlist(['ticks','locations','labels'],[-4,-3,-2,-1,0,1,2,3,4],['-4','-3','-2','-1','0','1','2','3','4']);h.z_ticks = tlist(['ticks','locations','labels'],[-1,0,1],['Point 1','Point 2','Point 3']);

3D plot of a surface (11)

See also

  • eval3dp — compute facets of a 3D parametric surface
  • genfac3d — Compute facets of a 3D surface
  • geom3d — projection from 3D on 2D after a 3D plot
  • param3d — plots a single curve in a 3D cartesian frame
  • plot3d1 — 3D gray or color level plot of a surface
  • clf — Clears and resets a figure or a frame uicontrol
  • gca — Return handle of current axes.
  • gcf — Return handle of current graphic window.
  • close — Closes graphic figures, progression or wait bars, the help browser, xcos, the variables browser or editor.
  • delete — delete a graphic entity and its children.
  • axes_properties — description of the axes entity properties
3D plot of a surface (2025)

FAQs

What is a 3D response surface plot? ›

A 3D surface plot is a three-dimensional graph that is useful for investigating desirable response values and operating conditions. A surface plot contains the following elements: Predictors on the x- and y-axes. A continuous surface that represents the response values on the z-axis.

What is a surface plot in 3D plot? ›

A Surface Plot is a representation of three-dimensional dataset. It describes a functional relationship between two independent variables X and Z and a designated dependent variable Y, rather than showing the individual data points. It is a companion plot of the contour plot.

What is a 3D surface contour plot? ›

Contour plots display the 3-dimensional relationship in two dimensions, with x- and y-factors (predictors) plotted on the x- and y-scales and response values represented by contours. A contour plot is like a topographical map in which x-, y-, and z-values are plotted instead of longitude, latitude, and elevation.

What is a 3D surface chart? ›

A Surface chart (or 3D Surface plot) is a chart type used for finding the optimum combinations between two sets of data. As in a topographic map, the colors and patterns indicate the areas that are in the same range of values.

What is a 3D plot called? ›

Plot3D is also known as a surface plot or surface graph. Plot3D evaluates f at values of x and y in the domain being plotted over and connects the points {x,y,f[x,y]} to form a surface showing how f varies with x and y.

What is a surface in 3D modeling? ›

Surface modeling gives you the ability to build out a visual representation of an object's exterior and its contours. In other words, it's a surface. These objects can be mechanical components like an engine - or complex organic shapes like animals.

What is a surface in 3D math? ›

Surfaces in Three-Space. The graph of a 3-variable equation which can be written in the form F(x,y,z) = 0 or sometimes z = f(x,y) (if you can solve for z) is a surface in 3D.

How to interpret a 3D contour plot? ›

How to interpret contour plot?
  1. Contour plots can indicate peaks or valleys within the range of X and Y at the center of concentric shapes.
  2. If the contour lines are spaced close to each other, then the values change rapidly while if the contour lines are spaced far apart then the z values change more slower.

What is the equation for a 3D contour plot? ›

Graphing a Surface in Three Dimensions

Intersecting the graph of the function are horizontal planes with equations of the form z = k, for various values of the constant k. The curve formed by the intersection of z = f(x, y) and the plane z = k is the curve in the contour plot defined by the equation f(x, y) = k.

What is 3D surface rendering? ›

Surface rendering involves the careful collection of data on a given object in order to create a three-dimensional image of that object on a computer.

When to use a 3D surface plot? ›

Use 3D Surface Plot to examine the relationship between a response variable (Z) and two predictor variables (X and Y), by viewing a three-dimensional surface of the predicted response. You can choose to represent the predicted response as a smooth surface or a wireframe.

What is a surface plot? ›

Introduction. Surface plots are diagrams of three-dimensional data. Rather than showing the individual data points, surface plots show a functional relationship between a designated dependent variable (Y), and two independent variables (X and Z). The plot is a companion plot to the contour plot.

What is 3D surface description? ›

A 3D surface model is a digital representation of features, either real or hypothetical, in three-dimensional space. Some simple examples of 3D surfaces are a landscape, an urban corridor, gas deposits under the earth, and a network of well depths to determine water table depth.

What is a 3D surface model? ›

A 3D surface model is a digital representation of features, either real or hypothetical, in three-dimensional space. Some simple examples of 3D surfaces are a landscape, an urban corridor, gas deposits under the earth, and a network of well depths to determine water table depth.

What is 3D surface imaging? ›

The principle of structured-light 3D surface imaging techniques is to extract the 3D surface shape based on the information from the distortion of the projected structured-light pattern. Accurate 3D surface profiles of objects in the scene can be computed by using various structured-light principles and algorithms.

What is the purpose of response surface design? ›

Response Surface Modeling is used in product and process design since it helps optimize processes and understand the interplay between various factors, which is sometimes very intricate because of the concurrent presence of several independent variables.

What is a 3D cone plot? ›

A cone plot is the 3D equivalent of a 2D quiver plot, i.e., it represents a 3D vector field using cones to represent the direction and norm of the vectors. 3-D coordinates are given by x , y and z , and the coordinates of the vector field by u , v and w .

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Corie Satterfield

Last Updated:

Views: 6600

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.