latex TickLabelInterpreter in Matlab 2011b

2 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by