2

figure1I have a contour plot to which I have added labels along the contour lines in Matlab. The labels have a white box around them that I would like to turn off. All matlab tutorials show their result with not background and when I check the background specification for 'annotation' it comes back as 'none'. Any ideas would be greatly appreciated! I have tried a few things which can be viewed in my script:

[latlim2, lonlim2] = meshgrid(latlims,lonlims);
figure
axesm('mercator', 'MapLatLim', latlim, 'MapLonLim', lonlim,...
    'Frame', 'on', 'Grid', 'off', 'MeridianLabel', 'on', 'ParallelLabel', 'on')
setm(gca,'mlabelparallel',-20)
load coastlines
hold on
[f,g] = contourfm(latlim2, lonlim2, spdenso, 'LineColor', 'none');
[c,h] = contourm(latlim2, lonlim2, hgtanom1,'ShowText', 'off','LineColor', 'w', 'LineWidth', 3);
clabel(c,h)
t = annotation('ShowText')
t.BackgroundColor = 'none'
t.EdgeColor = 'none'
t.Color = 'none'
t.FaceAlpha = 0

1 Answers1

1

You should use clabelm, since you use contourm function, and a text_handle is needed as mentioned by (https://www.mathworks.com/matlabcentral/answers/91404-why-do-the-text-boxes-created-by-the-clabel-function-not-maintain-their-background-color-in-matlab-7). so the codes would be:

[c,h] = contourm(latlim2, lonlim2, hgtanom1);
text_handle = clabelm(c,h);
set(text_handle,'BackgroundColor', 'none', 'Fontsize',8);
D.Zhang
  • 9
  • 3