Specify location of clabel
    조회 수: 38 (최근 30일)
  
       이전 댓글 표시
    
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');
댓글 수: 0
답변 (2개)
  Kelly Kearney
      
 2020년 7월 17일
        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.
댓글 수: 0
  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 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.
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

