I am plotting 4 maps in one figure and I want to add text at left bottom of each subplot. If given a fix lat and lon range, I can assign a location to the text like:
text(lon,lat,texts);
or I can use relative location like: annotation(figure1,'textbox', [distance1 distance2 width height] ) for each subplot.
BUT what if I want to make a function that always put the text at the left bottom of each subplot given any size of the map?
For example, my current function can make worldmaps with texts in each subplot like this:
the code is: text(-17790000,-3064000,texts,'fontsize',13);
but the text won't show up if I am plotting a continent rather than the globe:
Any solution for that?
Thanks!

 채택된 답변

Star Strider
Star Strider 2021년 5월 6일

0 개 추천

Use xlim and ylim to make the text positions relative to the axes —
x1 = linspace(0,10, 25);
y1 = exp(-0.1*x1);
x2 = linspace(-1,1, 25);
y2 = exp(-0.75*x2) .* sin(2*pi*x2);
subplot(2,1,1)
plot(x1, y1)
grid
text(min(xlim), min(ylim), sprintf('Text for subplot %d', 1), 'Horiz','left', 'Vert','bottom')
subplot(2,1,2)
plot(x2, y2)
grid
text(min(xlim), min(ylim), sprintf('Text for subplot %d', 2), 'Horiz','left', 'Vert','bottom')
.

댓글 수: 4

Hannah
Hannah 2021년 5월 6일
I knew it would be simple! Thank you soooo much!
Star Strider
Star Strider 2021년 5월 6일
As always, my pleasure!
Milo Fitzpatrick
Milo Fitzpatrick 2022년 5월 31일
Hi! is there a way I can adjust this in order to place the text into the top right hand corner please!
Thank you
Hannah
Hannah 2022년 5월 31일
You can use replace min(xlim) by max(xlim) etc.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2021년 5월 6일

댓글:

2022년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by