Figure title/labels in LaTex cutoff

조회 수: 14 (최근 30일)
Peter Peterson
Peter Peterson 2011년 3월 6일
댓글: Daniel 2020년 10월 15일
Hi. If you run a code like title('$$\frac{1}{2}$$','interpreter','latex','fontsize',20) Matlab will set the title '1/2' on a figure window, neatly written in LaTex. However, the estimated size of this text is smaller than it really is, so the upper most part is cut off from the figure (hidden underneath the menubar)
I've tried to come up with a general solution using position, outerposition, extent, etc... But I haven't had any luck. The same is the case for x- & ylabels, written with LaTex.
Anyone out there who has a solution, or is up for the challenge to find one? Thank you!

답변 (4개)

jay
jay 2012년 4월 27일
% in order to make matlab to do not "cut" latex-interpreted axes labels %
set(gca, Units,normalized, Position,[0.15 0.2 0.75 0.7]);
Then play around with the values in 'Position' until the frame looks right.
  댓글 수: 2
Johanna
Johanna 2014년 3월 29일
Thank you! It worked perfectly <3
Daniel
Daniel 2020년 10월 15일
Apparently, this won't work in TiledLayout: "Setting this property has no effect when the parent container is a TiledChartLayout."
Any other solutions? My colorbar label is being cut off.

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


Fangjun Jiang
Fangjun Jiang 2011년 3월 7일
what if you adjust the font size? title('$$\frac{1}{2}$$','interpreter','latex','fontsize',10) looks acceptable to me when the figure is in its default window size.
title('$$\frac{1}{2}$$','interpreter','latex','fontsize',20) looks good when the figure window is in full screen.
  댓글 수: 1
Peter Peterson
Peter Peterson 2011년 3월 7일
True, but that really isn't the point here. The fontsize 20 is just to make an easy example. Fontsize 1 would produce the same error, for a bigger (higher) LaTex-text. Fontsize 20 works fine for normal (non-LaTex) interpretation of the text. It's the LaTex-interpretation, not the fontsize, which is the problem

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


Germán
Germán 2011년 5월 17일
I also get the same issue with the Tex interpreter, it usually cuts the \rangle or \langle character in ylabel or xlabel depending the font size.

Peter
Peter 2012년 3월 22일
편집: Walter Roberson 2017년 11월 15일
I have the same problem, when using the FEX contribution fig in combination with for example:
xlabel('time $t$','Interpreter','latex');
fig('units','centimeters','width',14,'height',4,'font','Helvetica','fontsize',16)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by