我正在使用以下代码来保存数字:
fig1=figure('visible','off');
b = bar(bar_res);
x={'a' ;'b' ;'c'; 'd' ;'e'; 'f' ;'g'; 'h';...
'i'; 'j' ;'k'; 'l'; 'm'; 'n' ;'o'; 'p' ;'q' ;'r'; 's';...
't';'u'};
set(gca,'XTickLabel',x,'XTick',1:21);
rotateXLabels( gca, 90 );
with=char('Res with dash');
without=char('Res without dash');
legend('Reference',with,without,'Location','northwest');
set(gca,'FontSize',16);
y=ylabel('Number of trials','rot',90,'FontSize',18);
set(y,'Units','Normalized','Position',[-0.15, 0.5, 0]);
savefig('a.fig');
saveas(gca, 'a.png');
但我不知道为什么右边有额外的空白区域,如下图所示:
2 回答
只需使用
xlim
设置 x-limits :例:
顺便说一句,如果你有 Matlab R2014b 或更高,你不再需要
rotateXLabels
. 只需使用:一个简单的解决方案可能是你打电话给
axis tight
. 但是它可能不是您想要的结果,因为它确实删除了绘图边界处的小空格 .