set

Sets property values for graphics handles.

Syntax

set(handle, p, v)

set(h-vector, str-cell, v-cell)

Inputs

handle
Graphics handle.
Type: char
Dimension: string
p
Property to be modified.
Type: string
Dimension: scalar
v
Value of property to be modified.
Type: double | char | logical | struct | cell | integer
Dimension: scalar | vector | matrix
h-vector
Vector of the graphics handles.
Type: vector
str-cell
A cell array containing the properties to be set.
Type: cell
v-cell
A cell array containing the values to be set. The cell array's dimensions can either be MxN, where M is the number of handles and N is the number of properties, or, 1xN, where N is the number of properties. If the cell array's dimensions are 1xN, then the same properties/values are applied to all graphics object handles included in h-vector.
Type: cell

Examples

Simple set example:
clf;
titleHandle = get(gca, 'title')
set(titleHandle, 'string', 'New title')
set(titleHandle, 'color', [255 0 0])


Figure 1. Set one property
Set multiple properties to one graphics handle:
clf;
titleHandle = get(gca, 'title')
set(titleHandle, {'string', 'color', 'fontSize', 'fontweight'}, {'New title', [136 0 21], 18 'bold'})


Figure 2. Set multiple properties to a single handle
Set multiple properties to multiple handles:
clf;
ph = plot(rand(10,5));
set(ph, {'color','linewidth'}, {'r', 1;'b', 2;'g', 3;'c', 4;'y', 5})


Figure 3. Set multiple properties
Set the same values to all graphics handles:
clf;
ph = plot(rand(10,5));
set(ph, {'color','linestyle'}, {'r', '--'})


Figure 4. Set the same values to all handles

Comments

set can be used to set properties of differrent graphics objects, including root, figure, axes, line, text, and surface, for example. For a complete list of the available properties for each graphics object, please see Properties for Graphics Object.