Only the ylabel does not change to latex interpreter

조회 수: 25 (최근 30일)
MWolf
MWolf 2021년 4월 26일
댓글: Star Strider 2021년 4월 26일
I'm trying to make a plot on the title and both axes are written in the standard Latex font. My problem is however that only the y-label will stay in the standard Matlab font. Does anyone have an idea how to get this y-label in the Latex font just like the x-label and title?
I've also tried:
set(0,'defaulttextinterpreter','latex')
and
set(groot,'defaultAxesTickLabelInterpreter','latex')
without any succes.
The complete plotting code is:
figure(3)
hold on
set(gca,'TickLabelInterpreter','latex')
plot(s_to_ms*0.5*(1:length(avgmeantimeframes(1,:))),s_to_ms*mutopixel*avgmeantimeframes(1,:)/2000,'LineWidth',2.5)
title('Average velocity for different applied pressures','FontSize',12)
ax = gca; % current axes
ax.FontSize = 16;
xlim([0 33000])
ylim([1.6 2])
xlabel('Time [ms]');
ylabel('Average droplet velocity [µ/ms]');
yL = get(gca,'YLim');
line([4500 4500],yL,'Color','#EDB120','LineStyle','--');
line([9500 9500],yL,'Color','#EDB120','LineStyle','--');
line([14500 14500],yL,'Color','#EDB120','LineStyle','--');
line([19500 19500],yL,'Color','#EDB120','LineStyle','--');
line([24500 24500],yL,'Color','#EDB120','LineStyle','--');
line([29500 29500],yL,'Color','#EDB120','LineStyle','--');
text(1000,1.62,'1 Bar','FontSize',12,'FontWeight','bold')
text(5500,1.62,'2 Bar','FontSize',12,'FontWeight','bold')
text(10500,1.62,'2,5 Bar','FontSize',12,'FontWeight','bold')
text(15500,1.62,'3 Bar','FontSize',12,'FontWeight','bold')
text(20500,1.62,'3,5 Bar','FontSize',12,'FontWeight','bold')
text(25500,1.62,'4 Bar','FontSize',12,'FontWeight','bold')
text(30500,1.62,'1 Bar','FontSize',12,'FontWeight','bold')
set(gcf,'position',[600,300,1000,562.5])
hold off
With the following figure as result

채택된 답변

Star Strider
Star Strider 2021년 4월 26일
The LaTeX interpreter doesn’t like the ‘µ’.
Try this:
ylabel('$Average droplet velocity [\mu/ms]$', 'Interpreter','latex');
I needed to add the $ and specify the interpreter because I can’t run the code (no data).
  댓글 수: 4
MWolf
MWolf 2021년 4월 26일
Thank you, this works!
Star Strider
Star Strider 2021년 4월 26일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by