Fix Extra Space in Figure using xlabel

8 views (last 30 days)
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 Comment
jamesdg
jamesdg on 12 Feb 2015
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:

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Feb 2015
See if the FEX contribution export_fig can save it correctly for you. It’s gotten great reviews.
  6 Comments
jamesdg
jamesdg on 12 Feb 2015
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 on 12 Feb 2015
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!