필터 지우기
필터 지우기

Multiple subplots with one dynamic super title using annotation

조회 수: 2 (최근 30일)
Ali Kareem
Ali Kareem 2016년 7월 24일
답변: dpb 2016년 7월 24일
Hello,
Please, I am trying to use one super title for multiple subplots. I used annotation to accomplish that. The annotation is inside a loop. The problem is the annotation working fine when its not dynamic but unfortunately, I need to change title when I use Loop
I used below code which is working when there is no change on title.(This is just an example of random numbers)
clc;
clear;
a=rand(10,10);
for i=1:3
h(1)=subplot (2,2,1);
plot (a(:,1),a(:,2));
set(h(1),'Position',[.1 .35 .35 .5])
h(2)=subplot (2,2,2);
plot (a(:,1),a(:,2));
set(h(2),'Position',[.55 .35 .35 .5])
annotation('textbox', [0 0.85 1 0.1],'String',...
'Test text Number=1','EdgeColor', 'none','HorizontalAlignment', 'center')
end
I tried to change annotation line as below but it is not working
annotation('textbox', [0 0.85 1 0.1],'String',...
'Test text Number=%d',i,'EdgeColor', 'none','HorizontalAlignment', 'center')
I do not want to use external function in my code such as (suptitle,suplabel..etc)
Thanks

채택된 답변

dpb
dpb 2016년 7월 24일
annotation doesn't have the facilities of sprintf, etc., you've got to build the string
annotation('textbox', [0 0.85 1 0.1],'String',...
num2str(i,'Test text Number=%d'),'EdgeColor', 'none','HorizontalAlignment', 'center')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by