MATLAB Function Reference
  Go to function:
    Search    Help Desk 
light    Examples

Create a Light object

Syntax

Description

light creates a Light object in the current Axes. Lights affect only Patch and Surface object.

light('PropertyName',PropertyValue,...) creates a Light object using the specified values for the named properties. MATLAB parents the Light to the current Axes unless you specify another Axes with the Parent property.

Remarks

You cannot see a Light object per se, but you can see the effects of the light source on Patch and Surface objects. You can also specify an Axes-wide ambient light color that illuminates these objects. However, ambient light is visible only when at least one Light object is present and visible in the Axes.

You can specify properties as property name/property value pairs, structure arrays, and cell arrays (see set and get for examples of how to specify these data types).

See also the Patch and Surface AmbientStrength, DiffuseStrength, SpecularStrength, SpecularExponent, SpecularColorReflectance, and VertexNormals properties. Also see the lighting and material commands.

Examples

Light the peaks surface plot with a light source located at infinity and oriented along the direction defined by the vector [1 0 0], that is, along the x-axis.

Object Hierarchy

Setting Default Properties

You can set default Light properties on the Axes, Figure, and Root levels:

Where Property is the name of the Light property and PropertyValue is the value you are specifying. Use set and get to access Light properties.

The following table lists all Light properties and provides a brief description of each. The property name links take you to an expanded description of the properties.

Property Name
Property Description
Property Value
Defining the Light
Color
Color of the light produced by the Light object
Values: ColorSpec
Position
Location of Light in the axes
Values: x-, y-, z-coordinates in Axes units
Default: [1 0 1]
Style
Parallel or divergent light source
Values: infinite, local
Controlling the Appearance
SelectionHighlight
This property is not used by Light objects
Values: on, off
Default: on
Visible
Make the effects of the Light visible or invisible
Values: on, off
Default: on
Controlling Access to Objects
HandleVisibility
Determines if and when the the Line's handle is visible to other functions
Values: on, callback, off
Default: on
HitTest
Light objects do use this property
Values: on, off
Default: on
General Information About the Light
Children
Light objects have no children
Values: [] (empty matrix)
Parent
The parent of a Light object is always an Axes object
Value: Axes handle
Selected
Light objects do use this property
Values: on, off
Default: on
Tag
User-specified label
Value: any string
Default: '' (empty string)
Type
The type of graphics object (read only)
Value: the string 'light'
UserData
User-specified data
Values: any matrix
Default: [] (empty matrix)
Properties Related to Callback Routine Execution
BusyAction
Specify how to handle callback routine interruption
Values: cancel, queue Default: queue
ButtonDownFcn
This property is not used by Light objects
Values: string
Default: empty string
CreateFcn
Define a callback routine that executes when a Light is created
Values: string (command or M-file name)
Default: empty string
DeleteFcn
Define a callback routine that executes when the Light is deleted (via close or delete)
Values: string (command or M-file name)
Default: empty string
Interruptible
Determine if callback routine can be interrupted
Values: on, off
Default: on (can be interrupted)
UIContextMenu
This property is not used by Light objects
Values: handle of a Uicontrextmenu



[ Previous | Help Desk | Next ]