# adding lines to a contour plot with labels

조회 수: 52 (최근 30일)
HC98 2023년 7월 5일
편집: KALYAN ACHARJYA 2023년 7월 5일
I want to produce something like this
But I'm not sure how- how might one add lines and labels to contor plots?
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Aakash 2023년 7월 5일
Hi,
What I understand from your question is that you want to add line plots in a contour plot, for that:
1. Use the contour or contourf function to create the contour plot of your data.
2. To add lines to the contour plot, you can use the hold on command to enable multiple plot overlays. Then, use the plot function to draw the desired lines. (do this for each line)
for example:
hold on;
x_line = [x1, x2]; % x-coordinates of the line endpoints
y_line = [y1, y2]; % y-coordinates of the line endpoints
plot(x_line, y_line, '--');
3. To add labels to the contour plot, you can use the text function to place text at specific coordinates on the plot.
for example:
x_label = x_coordinate; % x-coordinate of the label
y_label = y_coordinate; % y-coordinate of the label
label_text = 'a'; % Text for the label
text(x_label, y_label, label_text, 'FontSize', 12, 'Color', 'black');

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

### 답변 (1개)

KALYAN ACHARJYA 2023년 7월 5일
편집: KALYAN ACHARJYA 2023년 7월 5일
x1 = -10:0;
y1=10:-1:0;
x2 = 0:10;
y2=0:10;
x3=zeros*(0:10);
y3=0:10;
plot(x1,y1,x2,y2,x3,y3,'--');
text(x1(round(length(x1)/2)),y1(round(length(y1)/2))+1,'a');
text(x2(round(length(x2)/2)),y2(round(length(y2)/2))+1,'c');
text(x3(round(length(x3)/2)),y3(round(length(y3)/2))+1,'b');
You can also create the corresponding function equation as per requirement since it have simple linear relationship.

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

### 카테고리

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

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by