Files
hartman-server/qhtcp-workflow/apps/matlab/ezview/Axes2FigPrint.m

24 lines
649 B
Matlab
Executable File

close all
figure('units','pix','pos',[200 200 850 750])
ax=axes;
plot((1:10).^2)
set(ax,'units','pix')
legend('x^2')
xlabel('X Label','fontsize',12)
ylabel('Y Label','fontsize',12)
title('Title','fontsize',24)
drawnow
% Now capture the axes and labels.
P=get(ax,'pos');
T=get(ax,'tightinset');
h=[P(1)-T(1)-5 P(2)-T(2)-5 P(3)+P(1)/2+T(3)+15 P(4)+P(2)/2+T(4)+10];
F=getframe(gcf,h);
[X,Map]=frame2im(F);
% I put the funny background color so the captured area stands out.
figure('color',[.6 .2 .2],'units','pix','pos',[26 33 1184 925])
image(X)
set(gca,'visible','off')
axis normal
imwrite(X,'myimage.jpg') % save the image