Function Repository Resource:

SectionPlot3D

Plot a surface together with various types of sections of the surface

Contributed by: Dennis M Schneider
 ResourceFunction["SectionPlot3D"][f,{x,xmin,xmax},{y,ymin,ymax},opts] generate a three-dimensional plot of f as a function of x and y highlighting sections specified by opts. ResourceFunction["SectionPlot3D"][f,{x,xmin,xmax},{y,ymin,ymax},{{gx,gy},…},{t,tmin,tmax}}] plots the section of the surface determined by the generalized cylinders described parametrically by {{gx,gy},…},{t,tmin,tmax}.

Details and Options

Generalized cylinders defined by the parametric function g need not be circular.
Generalized cylinders are defined as in MathWorld.
Sections defined in opts must include options values for at least one of the following: "XSection", "YSection", "ZSection", "VSection", or "OSection".
ResourceFunction["SectionPlot3D"] has the same options as Plot3D with the following additions and changes:
 "ColorFunctionSection" Automatic specifies the color function(s) for the section "ColorFunctionSurface" Automatic specifies the color function(s) for the surface "CylinderBase" Automatic determines the z-value to which cylinders are projected "CylinderRange" Automatic determines the range of the cylinder "CylinderStyle" Opacity[0.4] specifies style for the cylinder; it ignores color specifications. "DrawCylinder" True whether to draw the cylinder "DrawPoint" {} a list of points to be included in the plot "DrawPointStyle" {{Red,PointSize[Large]}} styles to be applied to the points specified with the option "DrawPoint" "OSection" {} draws an oblique section determined by functions of the form z=f[x],z=g[y], or z=h[x,y] "OSectionStyle" {{Red,Tube[.02]}} styles to be applied to the oblique sections "PlotPointsSection" 75 specifies how many initial sample points to use in plotting sections PlotStyle Opacity[0.7] graphics directive for the style for each surface "SectionStyle" {{Red,Tube[.02]}} styles to be applied to sections defined parametrically by {gx,gy} "Surface" True whether to return the surface in the plot "VSection" {} draws vertical section(s) for a function or list of functions of the form y=f[x] or x=g[y] "VSectionStyle" {{Red,Tube[.02]}} styles to be applied to the vertical sections "XSection" {} draws vertical sections parallel to the yz-plane determined by the value or list of values of x "XSectionStyle" {{Red,Tube[.02]}} styles to be applied to the x-sections "YSection" {} draws vertical sections parallel to the xz-plane determined by the value or list of values of y "YSectionStyle" {{Red,Tube[.02]}} styles to be applied to the y-sections "ZSection" {} draws horizontal sections parallel to the xy-plane determined by the value or list of values of z "ZSectionStyle" {{Red,Tube[.02]}} styles to be applied to the z-sections

Examples

Basic Examples (1)

Plot a surface with a circular section:

 In[1]:=
 Out[1]=

Scope (3)

Plot a surface with all possible plane sections:

 In[2]:=
 Out[2]=

Plot a surface with both a plane section and a parametrically-defined section:

 In[3]:=
 Out[3]=

Plot two surfaces with their intersection illustrated with sections:

 In[4]:=
 Out[4]=

Options (29)

ColorFunctionSection (2)

Set a style for the sections:

 In[5]:=
 Out[5]=

Set a different style for each section:

 In[6]:=
 Out[6]=

ColorFunctionSurface (2)

Set a style for the surface:

 In[7]:=
 Out[7]=

Set a color function for both the surface and the sections:

 In[8]:=
 Out[8]=

CylinderBase (1)

Set where to place the base of the cylinder:

 In[9]:=
 Out[9]=

CylinderRange (5)

Set the cylinder to be drawn from the top of the bounding box down to the surface:

 In[10]:=
 Out[10]=

Draw the cylinder both above and below the surface:

 In[11]:=
 Out[11]=

Draw the cylinder to full height:

 In[12]:=
 Out[12]=

Draw a cylinder from a base of -2 to the surface (this is the same as setting "CylinderBase" -2):

 In[13]:=
 Out[13]=

"CylinderRange" takes precedence over "CylinderBase":

 In[14]:=
 Out[14]=

CylinderStyle (1)

Apply a style to the cylinder:

 In[15]:=
 Out[15]=

DrawCylinder (1)

Suppress the plot of the cylinder:

 In[16]:=
 Out[16]=

DrawPoint and DrawPointStyle (1)

Add points and styles to the points:

 In[17]:=
 Out[17]=

OSection (1)

 In[18]:=
 Out[18]=

OSectionStyle (1)

 In[19]:=
 Out[19]=

PlotPointsSection (1)

Change the number of points used to plot the section(s). Since the Wolfram Language’s plotting commands use adaptive procedures to determine how many points to actually plot, we must turn off this feature by setting the option MaxRecursion:

 In[20]:=
 Out[20]=

PlotStyle (1)

Apply a style to the surface:

 In[21]:=
 Out[21]=

SectionStyle (1)

Apply a style to the section:

 In[22]:=
 Out[22]=

Surface (1)

Suppress the plot of the surface:

 In[23]:=
 Out[23]=

VSection (2)

 In[24]:=
 Out[24]=

VSections can be any function of x or y:

 In[25]:=
 Out[25]=

VSectionStyle (1)

Set a style:

 In[26]:=
 Out[26]=

XSection (1)

 In[27]:=
 Out[27]=

XSectionStyle (2)

Assign a style to the x-sections:

 In[28]:=
 Out[28]=

Plot several sections and suppress the plot of the surface:

 In[29]:=
 Out[29]=

YSection (1)

 In[30]:=
 Out[30]=

YSectionStyle (1)

Set a style for the y-sections:

 In[31]:=
 Out[31]=

ZSection (1)

 In[32]:=
 Out[32]=

ZSectionStyle (1)

Set a style for z-sections:

 In[33]:=
 Out[33]=

Possible Issues (6)

SectionPlot3D only allows one color function:

 In[34]:=
 Out[34]=

If one of the sections is outside the plot range, it is removed and a warning message is given:

 In[35]:=
 Out[35]=

"CylinderStyle" does not allow a color directive:

 In[36]:=
 Out[36]=

"SectionStyle" does not allow a opacity, dashing, or thickness directives. Opacity and dashing are dropped, and thickness is replaced by Tube:

 In[37]:=
 Out[37]=

"XSectionStyle", "YSectionStyle", "ZSectionStyle", "VSectionStyle", "OSectionStyle" do not accept opacity directives:

 In[38]:=
 Out[38]=

"VSection" must be set to one or more functions of x or y, but not both:

 In[39]:=
 Out[39]=

Publisher

Dennis M Schneider

Version History

• 1.0.0 – 10 October 2019