Display values on plot

조회 수: 69 (최근 30일)
EYKL
EYKL 2021년 12월 10일
댓글: Chunru 2021년 12월 10일
Dear all,
How do I display values on a plot (as shown in picture) or something similar to this for multiple subplots?
Thank you.

채택된 답변

Chunru
Chunru 2021년 12월 10일
편집: Chunru 2021년 12월 10일
You can use text. For example
t = 0:.01:2*pi;
x = cos(t);
plot(t, x);
text(0.2, 0.4, {'This', 'is', 'a', 'test'}, 'EdgeColor', 'r')
  댓글 수: 2
EYKL
EYKL 2021년 12월 10일
Hi @Chunru,
Suppose I have the following code:
R1(i,:) = diag(corr(y1(:,i),y2(:,i)));
r1(:,i) = ['r = ' num2str(R1(i,:))];
That already converts the r value into a string. How would I use text on for this?
Chunru
Chunru 2021년 12월 10일
if you have a string array
r = ["r=0.1"; "r=0.2"];
Then you can do the following:
t = 0:.01:2*pi;
x = cos(t);
plot(t, x);
text(0.2, 0.4, r, 'EdgeColor', 'r')

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by