*! version 1.0 21 Jun 2019

Title

surface -- Produce a Wireframe Surface plot

Syntax

surface
varlist(min=3
max=3)
[,
options]

Main
saving(string) saves the graph to a specified file name. Use the option saving(filename,replace) to overwrite a previous file.

round(#) specifies the precision of the x and y variables so that a wireframe can be drawn.

labelround(#) specifies the precision of the x, y and z automatic axes labels.

nlines(#) specifies the number of lines to be used in the surface, the default is 40.

nobox suppresses the drawing of the box around the surface.

orient(string) specifies which axes should be the x, y and z-axes.

xlabel(numlist) specifies the labelling on the x-axis.

ylabel(numlist) specifies the labelling on the y-axis.

zlabel(numlist) specifies the labelling on the z-axis.

nowire specifies that the data is plotted as a point and a dropline.

xtitle(string) specifies the title for the x-axis.

ytitle(string) specifies the title for the y-axis.

ztitle(string) specifies the title for the z-axis.

wcolor(string) specifies the color of the wireframe lines.

colorif(string) specifies a series of if statements and colors to vary the colours in some of the surface plots

* twoway options

Description

The function attempts to draw a wireframe plot from three variables. Var1 specifies the x-coordinate, var2 the y-coordinate and var3 the
z-coordinate. Alternatively the function can draw a circle at each point and add a straight line going down to the lowest point.

This function can handle data that is not in the form of a matrix of values. However if there are too many x- and y- values the function will
attempt to round the dataset values into a more reasonable spread of values. This will result in very messy figures. However in such a case it is
the impression that is needed. Many other statistical packages require a full matrix of values. This is not a problem using the nowire option.

At present the state of rotating the diagram is limited to interchanging the axes.

Options

Main

saving(string) this will save the resulting graph in filename.gph. If the file already exists then use the replace suboption.

round(#) data is automatically rounded if there are too many x and y values. This option controls the amount of rounding, for example round(1)
rounds the x and y values to the nearest integer.

labelround(#) specifies the precision of the x, y and z automatic axes labels.

nlines(#) 3 specifies the number of lines to be used in the surface, the default is 40.

nobox suppresses the drawing of the box around the surface.

orient(string) ) this function must take the letters xyz or a combination of them. Whichever letter comes first is the x-axis, second is y-axis and
third is the z-axis. Thus orient(zxy) means that var1 is now the y coordinates, var2 is the z-coordinates and var3 is the x-coordinates. This
is different from changing the variables around since the wireframe is still draw across the original x and y values. This is a crude attempt
to implement rotation to obtain a clearer picture.

xlabel(numlist) specifies the labelling on the x-axis.

ylabel(numlist) specifies the labelling on the y-axis.

zlabel(numlist) specifies the labelling on the z-axis.

nowire this suppresses the drawing of the wire frame in exchange for lines

xtitle(string) specifies the title for the x-axis.

ytitle(string) specifies the title for the y-axis.

ztitle(string) specifies the title for the z-axis.

wcolor(string) specifies the color of the wireframe lines.

colorif(string) specifies a series of if statements and colors to vary the colours in some of the surface plots. For example the scatter points could be coloured
red for low values and blue for high values.

* twoway options

Examples

surface x y z, saving(myfile) round(10) orient(zxy)

surface x y z, xtitle(my x title) ytitle(my y title) ztitle(my z title) saving(myfile,replace)

An "immediate" example without using a dataset. Please click the commands in order to avoid problems.

clear <--- NOTE all data is removed you may want to preserve first

set obs 900

gen x = int((_n - mod(_n-1,30) -1 ) /30 )

gen y = mod(_n-1,30)

gen z = normalden(x,10,3)*normalden(y,15,5)

surface x y z

surface x y z, zlabel(0 0.005 0.012) labelround(1) xtitle(X-variable)

surface x y z, zlabel(0 0.005 0.012) labelround(1) xtitle(X-variable) title(My surface plot)

surface x y z, zlabel(0 0.005 0.012) labelround(1) xtitle(X-variable) title(My surface plot) wc(red*.5)

surface x y z, zlabel(0 0.005 0.012) labelround(1) colorif(z<0.004 red z>0.004 blue) xtitle(X-variable) title(My surface plot) nowire

Author

Prof Adrian Mander, Cardiff University.

Email mandera@cardiff.ac.uk

See Also

Related commands:

Other Graphic Commands I have written:

batplot (if installed) ssc install batplot (to install)

cdfplot (if installed) ssc install cdfplot (to install)

contour (if installed) ssc install contour (to install)

drarea (if installed) ssc install drarea (to install)

graphbinary (if installed) ssc install graphbinary (to install)

metagraph (if installed) ssc install metagraph (to install)

palette_all (if installed) ssc install palette_all (to install)

plotbeta (if installed) ssc install plotbeta (to install)

plotmatrix (if installed) ssc install plotmatrix (to install)

radar (if installed) ssc install radar (to install)

trellis (if installed) ssc install trellis (to install)