Plot legend - cyrilic?

4 次查看(过去 30 天)
I G
I G 2020-1-28
回答: sanidhyak 2025-4-7
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?

回答(1 个)

sanidhyak
sanidhyak 2025-4-7
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!

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by