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

27 Ansichten (letzte 30 Tage)
Genhou SUN
Genhou SUN am 19 Okt. 2019
Beantwortet: Cimarron am 18 Jul. 2025
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.

Akzeptierte Antwort

Prasad Parameswaran
Prasad Parameswaran am 22 Okt. 2019
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.

Weitere Antworten (2)

Jelle Bakker
Jelle Bakker am 16 Feb. 2023
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 am 18 Jul. 2025
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.

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by