get
Reads a property of a graphics object.
Category: Data Import and Analysis > Data Import and Export
Syntax
v = get(h, 'PropertyName')
Returns the value of one property of the object with handle h.
s = get(h)
Returns a struct with all properties.
Description
get is the older, function-style way to read properties; dot notation such as h.LineWidth does the same. The handle 0 is the root object, and gcf and gca return the current figure and axes.
Change a property with set.
Input arguments
h- Handle of a figure, axes, line or other graphics object. An array of handles returns a cell array of values.
'PropertyName'- Name of the property, such as
'XLim','LineWidth','Color'.
Output arguments
v- Value of the property.
Example
Read line and axes properties
fig = figure('Visible', 'off');
ax = axes;
p = plot(1:3, [2 4 8], 'r--');
get(p, 'Color')
get(p, 'LineStyle')
get(ax, 'XLim')
Output
ans = 1×3
1 0 0
ans = '--'
ans = 1×2
1 3
Graphics here is created off screen, so only the property values are printed.