How to change font in legend while using latex interpreter

70 ビュー (過去 30 日間)
Marc Laub
Marc Laub 2021 年 1 月 14 日
編集済み: Cris LaPierre 2021 年 1 月 15 日
Hey,
I needed a fraction bar in my legend, so I used latex as interpreter, but now the legend font is in the default tex math font and not matlab default helvetica which is the font of all my other figures. How do I change the font back to helvetica when using latex as interpreter? I cant change it manually since in the figure editor the font of the legend is helvetica even if it is clearly not, the interpreter seems to overwrite this seeting.
l=legend('$\displaystyle\frac{max\:grain\:diameter}{number\:weighted\:mean\:grain\:diameter}$','interpreter','latex');
set(l, 'FontName', 'Helvetica')
also does not work.
l=legend('$\mathsf{\frac{max\,\,grain\,\,diameter}{number\,\,weighted\,\,mean\,\,grain\,\,diameter}}$','interpreter','latex');
is kind of ok, but somehow some letters are shifted into each other.
Is there a way to do so and if so how?
Best regards

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 15 日
編集済み: Cris LaPierre 2021 年 1 月 15 日
It does not appear to be possible to change the font. You can get roman or italic using \mathrm{} or \mathit{} respectively.
I did rebuild your expression using the equation editor in the live editor then copied the LaTeX. This was just to be sure I was using LaTeX the interpreter recognizes. This is created using the result and \mathrm{}.
plot(rand(1,10),'.')
legend('$\frac{\mathrm{max}\;\mathrm{grain}\;\mathrm{diameter}}{\mathrm{number}\;\mathrm{weighted}\;\mathrm{mean}\;\mathrm{grain}\;\mathrm{diameter}}$','Interpreter',"latex")
  3 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 1 月 15 日
Perhaps this post can prove helpful?
Marc Laub
Marc Laub 2021 年 1 月 15 日
nope, have tried it out, doesnt work. I also get the warning, but it I ignore it, mathsf is the closest I get to helvetica

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by