Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab: specify position of clabel on contour plot

Is there a way to specify the position of the labels on lines of a contour plot - rather than the default or using 'manual' (I have many plots and doing each manually won't help)? I'd like the label to be at the beginning of the contour line (i.e. at the top of the plot, max x position). I am using 'LabelSpacing' in 'clabel' to reduce the number of labels but can you specify where the first one starts? This because I want to overlay it on a pcolor and don't want the labels interfering. See below (where Hlim and Tlim are 1x23 vectors)

%% isolines
figure; 
rho=1025; g=9.81; rg64=(rho*g^2)/(64*pi);
Ht=Hlim';
Piso=(rg64.*(Ht.^2)*Tlim)./1000;
v=[10:50:250];
[C,h]=contour(Tlim,Ht,Piso,v,'--','LineColor', 'k');
th=clabel(C,h,'LabelSpacing',300);
strs=get(th,'String'); 
strs=strcat(strs,' kW/m'); 
set(th,{'String'},strs,'BackgroundColor','w');
like image 939
AlabaStar Avatar asked Jul 21 '14 13:07

AlabaStar


People also ask

How do you set contour levels in MATLAB?

To draw the contours at one height ( k ), specify levels as a two-element row vector [k k] . contour(___, LineSpec ) specifies the style and color of the contour lines. contour(___, Name,Value ) specifies additional options for the contour plot using one or more name-value pair arguments.

How do you add labels to a contour plot in MATLAB?

clabel( C ,'manual') adds upright labels at the locations you select with the mouse. Click the mouse or press the space bar to label the contour closest to the center of the crosshair. Press the Return key while the cursor is within the figure window to terminate labeling.

How do you specify color contour in MATLAB?

To use a different color for each contour line, specify "flat" . The mapping of colors from the colormap is determined by the contour values, the colormap, and the scaling of data values into the colormap. For more information about scaling data into the colormap, see Control Colormap Limits.


1 Answers

Here is the plot generated without modifying your code, with Hlim = [1:23]*.5; Tlim = [1:23]-2; It looks like it is giving the desired behavior with labels right at the top. Is this the desired output? example contour plot

like image 140
TallBrianL Avatar answered Sep 23 '22 19:09

TallBrianL