Clear Filters
Clear Filters

saving image using export_fig or saveas, messes up the axis labels

3 views (last 30 days)
The x axis, labels either gets chopped off in the saved file or mixed up with the x-axis marks. I need to save an image like this, with large axis titles, and marks.
close all;
sizee = 20;
h = figure(1)
line([0 1],[0 1])
g = get(h,'Currentaxes');
set(g,'FontSize',sizee,'FontName','Times');
xlabel('$X_1$','interpreter','latex','FontSize',sizee,'FontName','Times');
ylabel('$X_2$','interpreter','latex','FontSize',sizee,'FontName','Times');
xlim([-pi,pi])
ylim([-pi,pi])
h = figure(1) ;
set(h,'Color',[1.0 1.0 1.0]);
set(h,'units','normalized','outerposition',[0 0 1 1]);
export_fig(h,'test') % you can try either one saveas(h,'test.png')

Answers (1)

Image Analyst
Image Analyst on 25 Dec 2012
Move the X over with some non-breaking spaces (slash space):
xlabel('\ \ \ \ \ \ \ \ \ $X_1$','interpreter','latex','FontSize',sizee,'FontName','Times');
Use as many as you need to nudge the X over.
Either that or reduce your font size.

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!