フィルターのクリア

latex TickLabelInterpreter in Matlab 2011b

2 ビュー (過去 30 日間)
Slade Wilson
Slade Wilson 2017 年 5 月 19 日
回答済み: Julio Perez Olvera 2020 年 5 月 2 日
Hello,
I am trying to prepare some figures in Matlab for my Latex document. One part is done correctly with
set(0,'DefaultTextFontname', 'CMU Serif');
set(0,'DefaultAxesFontName', 'CMU Serif');
set(0,'defaulttextinterpreter','latex');
however, I can not have tick labels with the same font. I have tried with
set(ax,'TickLabelInterpreter', 'latex');
but I got error
Error using hg.axes/set The name 'TickLabelInterpreter' is not an accessible property for an instance of class 'axes'.
Then I tried with
F = getframe(gca);
set(gca, 'FontName', 'CMU Serif')
and then it is OK in Matlab, but exported eps. file with
saveas(gcf, name,'epsc');
in Latex does not have CMU Serif font on tick labels. However, legend and axis labels have.
Any suggestion? I use Matlab 2011b and obtained figures are attched.
Thanks in advance.

回答 (2 件)

KL
KL 2017 年 5 月 19 日
編集済み: KL 2017 年 5 月 19 日
ax = get(gca,'XTickLabel')
set(gca,'XTickLabel',ax,'FontName','CMU Serif')
  1 件のコメント
Slade Wilson
Slade Wilson 2017 年 5 月 19 日
編集済み: Slade Wilson 2017 年 5 月 22 日
Hi KL,
Thank you very much for your answer. It is still the same... It is fine in Matlab, but when exported eps file is compiled with latex, everything but tick labels has CMU Serif font, as it can be seen in attached figures.

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


Julio Perez Olvera
Julio Perez Olvera 2020 年 5 月 2 日
I have the same issue, any ideas why? See the MWE:
set(0,'DefaultTextFontName','Garamond',...
'DefaultTextFontWeight', 'normal', ...
'DefaultTextFontSize',13.5,...
'DefaultAxesFontName','Garamond',...
'DefaultAxesFontWeight', 'normal', ...
'DefaultAxesFontSize',12,...
'DefaultLineLineWidth',1.2,...
'DefaultLegendFontSize',11.5,...
'DefaultLegendFontSizeMode','manual',...
'DefaultLineMarkerSize',8.5,...
'defaulttextinterpreter','latex')
set(0,'DefaultFigureRenderer','opengl');
x=[10:2:1000];
y=[10:2:1000];
n=figure('Units','centimeters',...
'Position',[0 0 width height],...
'PaperPositionMode','auto');
scatter(x,y,10,'filled','^','k')
grid on
ax = gca;
ax.XTick = [0:200:1000];
ax.XTickLabel=({'0','200','400','600','800','1000'});
ax.YTick = [0:200:1000];
ax.YTickLabel=({'0','200','400','600','800','1000'});
txt2 = '234';
text(600,600,'Something','HorizontalAlignment','right','Interpreter','Latex')
ylabel('metres')
xlabel('metres')
title('Test');
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
print('-dpng','-r500','Name.png')
print('-depsc2','-r500','Name.eps')

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by