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.

example

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

collapse all

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")

Figure contains 3 axes objects. Axes object 1 with title Faceted Shading (Default) contains an object of type surface. Axes object 2 with title Flat Shading contains an object of type surface. Axes object 3 with title Interpolated Shading contains an object of type surface.

Input Arguments

collapse all

type — Color shading type

"faceted" (default) | "flat" | "interp"

Color shading type, specified as one of these options:

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