Specify location of clabel

38 Ansichten (letzte 30 Tage)
Addie
Addie am 17 Jul. 2020
Beantwortet: Cimarron am 18 Jul. 2025
I am trying to adjust the location of the contour labels. I would like them to be on the left side, as the right side is the more important side to see without distractions. I would like to find a solution besides the clabel 'manual' option as I'll be making several figures like this in a loop (also, for some reason when I use the manual option, the label selection figure is blank so it is a challenge to select the contour lines). I am using MATLAB 2020a. Thank you!
contourf(T,H,P,40,'edgecolor','none');
C=caxis;
caxis([C(1),C(2)]);
col = cmocean('matter',n_elem);
colormap(col);
cb = colorbar;
hold on
[c,h]=contour(T,H,D,10,'w');
h.LevelList=round(h.LevelList,1);
clabel(c,h,'LabelSpacing',1500,'FontSize',13,'color','white');
axis ij
h.LineWidth = 1.25;
set(gca,'XDir','reverse');

Antworten (2)

Kelly Kearney
Kelly Kearney am 17 Jul. 2020
I've used the FEX function gclabel in the past to do this sort of thing, though I haven't tested it in any recent versions of Matlab. Unfortunately, Matlab's built-in contour labeling is pretty limited.

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 D(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 half of the plot with something like
[c,h]=contour(flipud(T),H,fliplr(D),10,'w');
clabel(c,h,'LabelSpacing',1500,'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

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by