set
Sets properties of a graphics object.
Category: Data Import and Analysis > Data Import and Export
Syntax
set(h, 'PropertyName', value)
Sets one property of the object with handle h.
set(h, Name1, Value1, Name2, Value2)
Sets several properties in one call.
set(hArray, 'PropertyName', value)
Applies the same value to every object in the array.
Description
set is the function-style counterpart of dot assignment, so set(p, 'LineWidth', 3) and p.LineWidth = 3 do the same. Use it to restyle plots after they are drawn, or to apply one setting to many handles. The current value of a property can be read back with get.
Input arguments
h- Handle of a figure, axes, line or other graphics object.
'PropertyName', value- Property name and the value to give it.
Example
Restyle a line and the axes
fig = figure('Visible', 'off');
ax = axes;
p = plot(1:3);
set(p, 'LineWidth', 3, 'Color', 'r', 'Marker', 'o');
set(ax, 'XLim', [0 5]);
get(p, 'LineWidth')
get(p, 'Marker')
get(ax, 'XLim')
Output
ans = 3
ans = 'o'
ans = 1×2
0 5