Labelling colourbar using Latex

5 ビュー (過去 30 日間)
Roisin Coveney
Roisin Coveney 2022 年 6 月 21 日
コメント済み: Star Strider 2022 年 6 月 24 日
I am looking to label my colour bar as 'Probability density (µm^-2). I am using the followinng command however only the - is supescripted how can I have both the - and 2 as a superscript?
ylabel(c,'{\it Probability Density} (\mum^-2)','interpreter','Tex')

採用された回答

Star Strider
Star Strider 2022 年 6 月 21 日
Try this —
x = linspace(-3, 3, 50);
[X,Y] = ndgrid(x);
Z = exp(-(X.^2+Y.^2));
figure
surf(X, Y, Z)
grid on
hcb = colorbar;
hcb.Label.String = 'Probability density (\mum^{-2})'; % 'Tex' String
% hcb.Label.String = '$Probability\ density\ (\mu m^{-2})$'; % 'LaTeX' String
hcb.Label.Interpreter = 'tex';
The warning thrown by using the LaTeX string with the LaTeX interpreter is because of the backslant (\) characters, however without them, there are no spaces and the works run together.
.
  2 件のコメント
Roisin Coveney
Roisin Coveney 2022 年 6 月 24 日
Thanks that worked perfectly!
Star Strider
Star Strider 2022 年 6 月 24 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by