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

89 views (last 30 days)
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.

Accepted Answer

Subhadeep Koley
Subhadeep Koley on 8 Jan 2020
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!

More Answers (1)

NIDHI TIWARI
NIDHI TIWARI on 30 Mar 2022
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.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!