Why findobj cannot find a TexBox (annotation) object?
    조회 수: 23 (최근 30일)
  
       이전 댓글 표시
    
While HandleVisibility property of a TextBox object is 'on' by default,
fig = figure
txb = annotation('textbox',[0.5 0.5 0.5 0.5],'String','bar hoo')
class(txb)
ans =
    'matlab.graphics.shape.TextBox'
txb.Type % 
ans = 'textboxshape'
txb.HandleVisibility
ans = 'on'
findobj cannot find this txb.
findobj(fig,'Type','textboxshape')
ans = 
Why is this and how can I find this txb?
댓글 수: 0
채택된 답변
  Cris LaPierre
    
      
 2020년 12월 4일
        
      편집: Cris LaPierre
    
      
 2020년 12월 4일
  
      Try using the object handle (txb) directly.
plot(1:10)
str = 'Straight Line Plot from 1 to 10';
txb = annotation('textbox',[.2 .5 .3 .3],'String',str,'FitBoxToText','on');
% Use object handle
findobj(txb)
If you want to instead find the annotation without using the object handle, use findall instead.
findall(gcf,'Type','textboxshape')
댓글 수: 4
  Cris LaPierre
    
      
 2020년 12월 4일
				Good point. The underlying issue was handle visibility, as you pointed out below. I'll update my response to remove any confusion.
추가 답변 (1개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


