findobj
Find graphics objects with specific properties.
📝Syntax
h = findobj()
h = findobj(prop, value)
h = findobj(objhandles, prop, value)
h = findobj(objhandles, 'flat', ...)
h = findobj(objhandles, '-depth', d, ...)
h = findobj(..., '-property', prop)
h = findobj(..., '-regexp', prop, expr)
📥Input Arguments
Parameter Description
objhandles graphics object or array of graphics objects to search from.
prop property name as a character vector or scalar string.
value property value to match.
d nonnegative integer search depth, or Inf.
expr regular expression used to match a character property value.
📤Output Arguments
Parameter Description
h column array of matching graphics objects.
📄Description

findobj searches the graphics object hierarchy from the root object or from the supplied graphics objects. Objects whose HandleVisibility property is 'off' , and their descendants, are not returned.

Property predicates can be combined with '-and' , '-or' , '-xor' , and '-not' . Use cell arrays to group expressions.

💡Examples
close all
plot(rand(5))
h = findobj('Type', 'line')
close all
plot(1:10, 'Tag', 'linear')
h = findobj('-regexp', 'Tag', 'lin')
close all
plot(1:10, 'Tag', 'linear')
hold on
plot((1:10).^2, 'Tag', 'quadratic')
h = findobj('Type', 'line', '-and', '-not', {'Tag', 'linear'})
🔗See Also
grootgcfgcaisgraphicsgetset
🕔Version History
Version Description
1.17.0 initial version
Edit this page on GitHub