How does one change the font of a plot label that was created with the latex interpreter?

53 ビュー (過去 30 日間)
Hello. I need help with plotting a figure with the following y-axis label in Arial font.
ylabel('$\it\dot{K}\rm$ / units','Interpreter','latex','Fontname','Arial','FontSize', 18);
Unfortunately, the resulting figure retains the standard latex font for this y-axis, not the sans-serif font that I require. Furthermore, since I need the overhead dot in the label, I cannot use the default tex interpreter. Therefore, I've performed a bit of preliminary research into this topic and have attempted to include "\textsf{" within the aforementioned y-axis description only to receive the following warning.
"Warning: Error updating Text. Font cmss10 is not supported."
As a result, I downloaded the cmss10.ttf files from the following website and installed them into the appropriate cm folder within the C:\Program Files\MATLAB path location.
Once again, this did not solve the issue. In other forums (https://stackoverflow.com/questions/11212172/latex-fonts-in-matlab/11212673), it has been suggested that I could export my figure as a .eps file, open in a text editor, manually exchange the fonts there, and then reopen the figure as a PDF. However, I wasn't able to find detailed instructions on what text should be changed and thus I ran into another dead end.
If anyone has any insight on this issue, I would really appreciate the help. Thank you in advance.

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 1 月 8 日
Hi, Kent you can use below workaround to get sans-serif font in ylabel. This code generates an warning but gives the desired output.
plot(rand(3,10));
ylabel('$\mathsf{\stackrel {.}{K} / units}$', 'Interpreter', 'latex', 'fontweight','bold','fontsize',20);
mathsf_test.png
Hope this helps!

その他の回答 (1 件)

NIDHI TIWARI
NIDHI TIWARI 2022 年 3 月 30 日
In order to control the fonts it would be better to use tex interpreter. Copy the symbol directly from somewhere else instead of writing the latex code, e.g ylabel('Mean d_{f} (Å)','FontName', 'Arial', 'FontWeight', 'bold', 'Interpreter', 'tex') successfully updates to Arial font while ylabel('\textbf{Mean d$_{f}$ ($\AA$)}','FontName', 'Arial', 'Interpreter', 'latex') does not.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by