Control and use greek letter of the contour diagrams

5 ビュー (過去 30 日間)
mads skibsted
mads skibsted 2024 年 3 月 21 日
回答済み: Voss 2024 年 3 月 25 日
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 %.
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

回答 (1 件)

Voss
Voss 2024 年 3 月 25 日
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.

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by