shading - Set color shading of surfaces and patches - MATLAB (original) (raw)
Main Content
Set color shading of surfaces and patches
Syntax
Description
shading [type](#mw%5Ff580789b-d7d5-492a-816e-04967a69214a)
sets the color shading ofSurface
and Patch
objects in the current axes according to the specified shading type. For example, shading flat
sets the color shading of mesh line segments and faces to a constant color determined by the color value at the endpoint of the segment or the corner of the face that has the smallest index or indices.
shading
sets appropriate values for theEdgeColor
and FaceColor
properties depending on whether the Surface
or Patch
objects represent meshes or solid surfaces.
shading([ax](#mw%5F020c85fb-cc87-4974-bc70-b8d5e7f6b1e1),[type](#mw%5Ff580789b-d7d5-492a-816e-04967a69214a))
applies the shading type to the objects in the axes specified by ax
instead of in the current axes (gca).
Examples
Compare Shading Types
Call the tiledlayout
function to create a 2-by-2 tiled chart layout. Call the nexttile
function to create the axes. Then display three different spheres using different types of shading.
tiledlayout(2,2) nexttile sphere(10) title("Faceted Shading (Default)")
nexttile sphere(10) shading flat title("Flat Shading")
nexttile sphere(10) shading interp title("Interpolated Shading")
Input Arguments
type
— Color shading type
"faceted"
(default) | "flat"
| "interp"
Color shading type, specified as one of these options:
"faceted"
— Use flat shading with superimposed black mesh lines. This shading type is the default."flat"
— Use a constant color for each mesh line segment and face. The color is determined by the color value at the endpoint of the segment or the corner of the face that has the smallest index or indices."interp"
— Use interpolated coloring for each line segment and face. The interpolated coloring is based on the colormap index or true color value across the line or face.
When using the command form of shading
, you do not need to include quotes around these type
values. For example, you can useshading interp
. When using the function form instead of command form, you need to include single or double quotes around these type
values. For example, you can use shading("interp")
orshading(ax,"flat")
.
ax
— Axes object
axes object
Axes object. If you do not specify an axes object, then shading
sets the color shading properties for objects in the current axes.
Version History
Introduced before R2006a