Text Boxes on MATLAB not showing up

조회 수: 10 (최근 30일)
Hans123
Hans123 2019년 7월 3일
댓글: Star Strider 2019년 7월 3일
The text boxes are not showing up for my plot, I am not getting an error message either. Let me know what is wrong in this code
clear, clc, close all
farsemi = zeros(1,1);
thirdsemi=zeros(1,1);
CH4_3 =[3.03,2.75,2.58,2.44,2.30,2.27,2.19,2.11,2.03,1.97,1.91,1.83,1.79,1.74,1.71,1.65,1.62,1.5,960e-3,726e-3,730e-3,775e-3,739e-3,787e-3];
Step_3 =[3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,81,111,141,171,201,231,261];
plot(Step_3,CH4_3,'-*','LineWidth',2)
index = (CH4_3 >= 1.5);
plot(Step_3,CH4_3,'b-*','LineWidth',2);
hold on
plot(Step_3(index), CH4_3(index), 'r-*','LineWidth',2);
semifar = CH4_3(end);
far=CH4_3(CH4_3>1.4 & CH4_3<1.6);
third=CH4_3(end-1);
farsemi = (far-semifar)./semifar;
thirdsemi = (third-semifar)./third;
dim1=[0.15,0.2,1,1];
dim2=[0.8,0.2,1,1];
str1=sprintf('%.2f',farsemi);
annotation('textbox',dim1,'String',str1,'FitBoxToText','on','EdgeColor','b');
str2=sprintf('%.2f',thirdsemi);
annotation('textbox',dim2,'String',str2,'FitBoxToText','on','EdgeColor','r');

채택된 답변

Star Strider
Star Strider 2019년 7월 3일
The annotation object positioning convention remains something of a mystery to me.
So I have no idea why this works, it just does:
dim1=[0.15,0.2,0.1,0.1];
dim2=[0.8,0.2,0.1,0.1];
Experiment to get the result you want!
  댓글 수: 2
Hans123
Hans123 2019년 7월 3일
Star Strider, you are a blessing to all of us in this forum.
Thanks again!
Star Strider
Star Strider 2019년 7월 3일
As always, my pleasure!
I very much appreciate your compliment!

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

추가 답변 (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