I am currently trying to prepare some figures for a final draft of my paper. I have generated some data and plotted a histogram using histfit. I then attempt to label the data using xlabel. I then set the size of the histogram to save it.
All well and good. However, when I save the figure using saveas, I have a big space between the m and the 2. As expected, Matlab is interpreting this as LaTeX code and it's appearing as a superscript. However, I'd like to get rid of the space between the m and the 2.
What's strange is that if I save as an eps, I have this problem, but if I save as a pdf I don't. Here's my minimal working example:
hSize=[6.5,2.5];
A=50*rand(200,1);
histfit(A,20,'gamma')
xlabel('Measured Area (m^2)')
ylabel('Frequency')
set(gcf,'Color',[1 1 1],'PaperUnits','inches','PaperSize',hSize,...
'PaperPosition',[0 0 hSize]);
saveas(gcf, [mypath, '/example.eps'],'epsc') %replace mypath with your own path

댓글 수: 1

jamesdg
jamesdg 2015년 2월 12일
I didn't upload an image of the figure since I can't upload eps files, but here's a screenshot of my figure so you have an idea of what I mean:

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

 채택된 답변

Star Strider
Star Strider 2015년 2월 12일

0 개 추천

See if the FEX contribution export_fig can save it correctly for you. It’s gotten great reviews.

댓글 수: 6

daniel
daniel 2015년 2월 12일
weird, I have never had this problem... try export_fig on file exchange, its great.
jamesdg
jamesdg 2015년 2월 12일
I took a look and tried it out -- a great package. Unfortunately it gives me the same problem.
jamesdg
jamesdg 2015년 2월 12일
Again, that's only for the .eps file; as with saveas, I have no problems if I save as .jpg or .png. PDF gives me the same problem as EPS.
The only other thing I can think of is to see if using the 'Interpreter','latex' option would help. You can find information on LaTeX here. Its syntax is slightly different from TeX.
Otherwise, experiment with variations, such as:
xlabel('Measured Area (m^{2})')
or
xlabel('Measured Area (m²)')
It doesn’t seem that it would make a difference, but it might.
Thanks, the following worked (though it changed the font -- not a problem for me, but heads up for anyone using this in the future):
xlabel('Measured Area ($m^{2}$)','Interpreter','latex')
Star Strider
Star Strider 2015년 2월 12일
My pleasure!
I’ve had LaTeX work when other options didn’t. You can also specify the font in xlabel, but I’m not sure if all fonts work and play well with LaTeX.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

질문:

2015년 2월 12일

댓글:

2015년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by