Control and use greek letter of the contour diagrams
2 views (last 30 days)
Show older comments
Hi,
Do you know how I can control the labels better of this contour diagram. So it is only placed in the middle and not near the end.
And do you know how I can incrporate a greek letter in the labels of the contour diagram. Forexample \epsilon = 7 %.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1648166/image.jpeg)
figure; hold on ; box on
[CC,hh] = contour(x,y,z'*100,[1 3 8 11 15],'LineWidth',1.5,'edgeColor','#191970',"LabelFormat",@myfun);
[C,h] = contour(x,y,z'*100,[0.1 0.3 0.5 1.5 2 4 5 6 7 9 10 12 13 14],'LineWidth',1.5,'edgeColor','#7FFFD4',"LabelFormat",@myfun);
set(gca, 'XScale', 'log')
clabel(C,h,'labelspacing',500,'Interpreter','latex','fontsize',12)
clabel(CC,hh,'labelspacing',500,'Interpreter','latex','fontsize',12)
ylabel('Deviatoriq ampltiude, $q^{ampl} \ (\%)$','FontSize',17); xlabel('Number of cycles, $N$ (-)','FontSize',17,'FontName','times')
colororder(newcolors)
text(1E5,180,{' $p^{av} = 200 \ \mathrm{kPa}$',' $I_{d0} = 20 \ \%$'},'Interpreter','latex','fontsize',14)
text(2E3,180,{' $ = \varepsilon^{acc} \ $'},'Interpreter','latex','fontsize',16)
function labels = myfun(vals)
labels = vals + " \% ";
end
0 Comments
Answers (1)
Voss
on 25 Mar 2024
Here's how you can incorporate a Greek letter into the contour labels:
x = 10.^(0:6);
y = 0:10:200;
z = (1+y).*log10(x.')/4000;
figure; hold on ; box on
[CC,hh] = contour(x,y,z'*100,[1 3 8 11 15],'LineWidth',1.5,'edgeColor','#191970',"LabelFormat",@myfun);
[C,h] = contour(x,y,z'*100,[0.1 0.3 0.5 1.5 2 4 5 6 7 9 10 12 13 14],'LineWidth',1.5,'edgeColor','#7FFFD4',"LabelFormat",@myfun);
set(gca, 'XScale', 'log')
clabel(C,h,'labelspacing',500,'Interpreter','latex','fontsize',12)
clabel(CC,hh,'labelspacing',500,'Interpreter','latex','fontsize',12)
function labels = myfun(vals)
labels = "$\epsilon = " + vals + "\%$";
end
I don't know of a reliable way to control the placement of the labels, other than by playing with the labelspacing.
0 Comments
See Also
Categories
Find more on Labels and Annotations 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!