Plot legend - cyrilic?

4 Ansichten (letzte 30 Tage)
I G
I G am 28 Jan. 2020
Beantwortet: sanidhyak am 7 Apr. 2025
I need to make cyrilic legend in Matlab plot. I am doing it with:
legend({'прва.'}, 'Fontname','Times new roman', 'FontSize', 16);
It is nice font, but when I export my plot in eps and use it in Latex, it is not nice font anymore.
If I do it with
legend({'прва.'}, 'Interpreter', 'LaTeX', 'FontSize', 16);
it will be the not nice font in both, Matlab and Latex.
Also, Italic command does not work with cyrilic in plot legend.
What should I do to make nice plot and nice font for cyrilic in Latex?

Antworten (1)

sanidhyak
sanidhyak am 7 Apr. 2025
Hi @I G,
I understand that you are trying to add a Cyrillic legend to your MATLAB plot using the provided code and although it displays well in MATLAB, the font does not appear correctly when exported to EPS and used in LaTeX. Also, using the LaTeX interpreter causes the font to degrade both in MATLAB and in the LaTeX document, and italicizing Cyrillic text does not work as expected.
These issues arise because the EPS format has limited support for Unicode characters and font embedding, which affects the rendering of non-Latin scripts such as Cyrillic. Moreover, the LaTeX interpreter in MATLAB does not support Unicode, so it does not handle Cyrillic characters properly.
To resolve this issue, I recommend switching from EPS to PDF export using exportgraphics” function in MATLAB, which preserves Unicode characters and font styles more reliably.
Please refer to the corrected approach below:
figure;
% Example plot
plot(1:10);
% Cyrillic legend with proper font
legend({'прва.'}, 'FontName', 'Times New Roman', 'FontSize', 16, 'Interpreter', 'none');
% Export as PDF with vector content
exportgraphics(gcf, 'my_plot.pdf', 'ContentType', 'vector');
This approach would ensure that the Cyrillic text is preserved correctly with the desired font styling, and the output PDF can be directly included in LaTeX using \includegraphics{my_plot.pdf}.
Please refer to the below documentation on "exportgraphics" function for more details:
I hope this helps!

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by