When using contourf, is it possible to make a gap in contour lines so that the label is visible?
3 views (last 30 days)
Show older comments
Hi,
My contour plots are largely illegible, as the contour labels insist on plotting over the middle of the lines! Is there a way to specify a break in the contour line for the label to fit into? Here's an example picture so you can tell what I mean;
and here's some example code;
clearvars
zeta=-90:10:90;
r_um=0:10:200;
xaxis=-90:10:90;
angle_r_mat=rand(length(r_um),length(zeta));
ncont=3
prettycolours=ones(ncont,3);
prettycolours(ncont,:)=0.5;
[g,h]=contourf(zeta,r_um,angle_r_mat,ncont);set(gca,'FontSize',16)
set(h, 'linewidth', 1.5);
clabel(g,h,'fontsize',15)
set(gca,'Xtick',xaxis)
set(gca,'XtickLabel',xaxis)
colormap(prettycolours);
xlabel('\zeta(^o)','FontSize',16)
ylabel('r (\mu m)','FontSize',16)
title('partypartyparty')
grid on
xlim([-90, 90])
set(gca,'Layer','top')
So I just want a gap in the contour line so that you can read the label. I've tried the help files and goggling, but haven't come up with anything. Anybody know how to do this?
0 Comments
Answers (1)
Jeffrey
on 24 May 2014
Z = peaks;
[C,h] = contourf(Z,-10:2:10);
colormap(cool)
axis square
set(h,'Linestyle','none')
hold on
[C1,h1] = contour(Z,-10:2:10);
set(h1,'ShowText','on','LineColor','k','LabelSpacing',450,'LevelList',-10:2:10)
clabel(C1,h1,-10:2:10,'LabelSpacing',500,'Rotation',0)
1 Comment
Platon Patlakas
on 23 Sep 2017
How can I do the same with contourm and/or contourfm. Lines and clabels overlay and this is not looking nice.
Thanks in advance!
See Also
Categories
Find more on Purple in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!