Azzera filtri
Azzera filtri

latex TickLabelInterpreter in Matlab 2011b

2 visualizzazioni (ultimi 30 giorni)
Slade Wilson
Slade Wilson il 19 Mag 2017
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.

Risposte (2)

KL
KL il 19 Mag 2017
Modificato: KL il 19 Mag 2017
ax = get(gca,'XTickLabel')
set(gca,'XTickLabel',ax,'FontName','CMU Serif')
  1 Commento
Slade Wilson
Slade Wilson il 19 Mag 2017
Modificato: Slade Wilson il 22 Mag 2017
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.

Accedi per commentare.


Julio Perez Olvera
Julio Perez Olvera il 2 Mag 2020
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')

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by