How to set the position of the label in a contour plot?

조회 수: 25 (최근 30일)
Genhou SUN
Genhou SUN 2019년 10월 19일
답변: Cimarron 2025년 7월 18일
Dear all,
I need help in draw a contour plot. I got a contour plot using the following code:
[c2,h2]=contour(xx(6:300),yy(6:300),Theta_e(6:300,6:300),'--b','LineWidth',0.2,'ShowText','on','labelspacing', 700);
The postion of label in the blue lines are set with 'labelspacing'. But I want the position of the label in the blue lines at the end of the blue lines. I wonder how to do it.
Thanks in advance.

채택된 답변

Prasad Parameswaran
Prasad Parameswaran 2019년 10월 22일
The function "clabel" will solve the issue.
With "clabel(c,h,'manual')" command you can add the label at locations you select with the mouse. For further reference see this link.
  댓글 수: 1
Genhou SUN
Genhou SUN 2019년 10월 27일
Thanks a lot for your kind help. It is very helpful.

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

추가 답변 (2개)

Jelle Bakker
Jelle Bakker 2023년 2월 16일
You can also use seperate contour plots such that one of those plots only has contour lines on the left. You can then enable labels only for that one. The other contour plot will then not have any labels.

Cimarron
Cimarron 2025년 7월 18일
I know this is a very late reply, but I'm adding in case it helps others.
I had a similar problem. If you clabel a contour plot of a matrix Theta_e(i,j), it looks like clabel starts the labels near i=1,j=1. I was able to "trick" clabel into putting the labels on the other end of the contour lines with something like
[c,h]=contour(flipud(xx),yy,fliplr(Theta_e),10,'w');
clabel(c,h,'LabelSpacing',700,'FontSize',13,'color','white');
Your might have to play with different combinations of flipud() and fliplr() on the inputs to get the contour lines correct. Hope that helps.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by