set
Sets property values for graphics handles.
Syntax
set(handle, p, v)
set(h-vector, str-cell, v-cell)
Inputs
- handle
- Graphics handle.
- p
- Property to be modified.
- v
- Value of property to be modified.
- h-vector
- Vector of the graphics handles.
- str-cell
- A cell array containing the properties to be set.
- 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.
Examples
clf;
titleHandle = get(gca, 'title')
set(titleHandle, 'string', 'New title')
set(titleHandle, 'color', [255 0 0])
Figure 1. Set one property
clf;
titleHandle = get(gca, 'title')
set(titleHandle, {'string', 'color', 'fontSize', 'fontweight'}, {'New title', [136 0 21], 18 'bold'})
![](../../../../images/math_solutions/plots/setMultPropsToOne.png)
Figure 2. Set multiple properties to a single handle
clf;
ph = plot(rand(10,5));
set(ph, {'color','linewidth'}, {'r', 1;'b', 2;'g', 3;'c', 4;'y', 5})
![](../../../../images/math_solutions/plots/setMultProps.png)
Figure 3. Set multiple properties
clf;
ph = plot(rand(10,5));
set(ph, {'color','linestyle'}, {'r', '--'})
![](../../../../images/math_solutions/plots/setSinglePropToAll.png)
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.