Main Content

shading

Set color shading of surfaces and patches

    Description

    shading type sets the color shading of Surface 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 the EdgeColor and FaceColor properties depending on whether the Surface or Patch objects represent meshes or solid surfaces.

    example

    shading(ax,type) applies the shading type to the objects in the axes specified by ax instead of in the current axes (gca).

    Examples

    collapse all

    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

    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 use shading 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") or shading(ax,"flat").

    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

    See Also

    | | | | |