Effacer les filtres
Effacer les filtres

Contourm lines overlay labels (using clabelm)

7 vues (au cours des 30 derniers jours)
Platon Patlakas
Platon Patlakas le 23 Sep 2017
Modifié(e) : David Shohami le 22 Oct 2020
I use contourm in order to make a map and I want to have labels as well. The label background color is set to none. The lines are going through the labels and this is not looking nice. In some cases it is dificult to read the labels as well.
Does anybody know how to make a small gap in where the labels are placed?
This is a part of the code!
hold on
[c,h] =contourm(flipud(aody),flipud(aodx),flipud(rot90(aod)),5:5:60,'w','LineWidth',1);
t = clabelm(c,h);
set(t,'Fontsize',14)
set(t,'Color','w')
set(t,'BackgroundColor','none')
set(t,'FontWeight','bold')

Réponses (3)

Sebby RedRice
Sebby RedRice le 4 Sep 2018
Hello,
I personally havent done it but a co-worker had this 'work around' where she used contour instead of contourm.
The trick is to create an x and y meshgrid from matlab's domain instead of using the lat/lon coordinates that you would normally input in countourm. Here's an example where she did the countours with sea-level pressure:
%%%Code starts
%Find the matlab values of lat and longitudes. Must first create the domain, then go to graph editor and find the corresponding xlim and ylim
x1 = -0.515;
x2 = 0.52;
y1 = 0.358;
y2 = 1.032;
%Create grid data
y_file = linspace(y1,y2,Mj); %Mj and Mi are the number of grid cells in both direction
x_file = linspace(x1,x2,Mi);
[y,x]=meshgrid(y_file,x_file);
%Define pressure range
p_min = 950; % hPa
p_max = 1042; % hPa
dp = 4; % Distance between contours
%Create contour
[C,h]=contour(x,y,fld_p,p_min:dp:p_max,'k','LineWidth',1);
clabel(C,h,'FontSize',12,'FontWeight','bold')

Fehmi Dilmahamod
Fehmi Dilmahamod le 13 Déc 2017
Hi there, I have the same issue. Did you manage to solve it?
  1 commentaire
Platon Patlakas
Platon Patlakas le 13 Déc 2017
No actually. Left it like this! Sorry..

Connectez-vous pour commenter.


David Shohami
David Shohami le 22 Oct 2020
Modifié(e) : David Shohami le 22 Oct 2020
Not the solution you were looking for, but what I did was use
set (t, 'VerticalAlignment', 'cap');
which placed the labels just below the contour, instead of on top of it.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by