MATLAB only prints a part of my figure

Posted by simonty on Stack Overflow See other posts from Stack Overflow or by simonty
Published on 2012-07-05T09:12:43Z Indexed on 2012/07/05 9:15 UTC
Read the original article Hit count: 345

Filed under:
|
|

I'm trying to print my figure in Matlab, but it keeps screwing up and I have no idea why.

opslaan = figure(1);
        plot(1:handles.aantal,handles.nauw,'-r','LineWidth',1.5);
        xlabel(gca,sprintf('Framenummer (%g ms per frame)',60/handles.aantal));
        ylabel(gca,'dB');
        set(gca,'YGrid','on');
        yAsMax = ceil( ceil(max(handles.nauw)) / 2) * 2;
        axis([0 handles.aantal 0 yAsMax]);
        pause(1);
        print -dpng image.png 

The first line is just plotting the data on my figure, then labeling x and y, turning on grid and caculating the y-axis like I want it. This all works great and Matlab shows it like I want it in the Figure window. When saving to .png / .jpeg / .eps it goes wrong and only prints the bottom left corner (473x355 pixels), the rest just disappeared.

When exporting manually via File -> Save As, it works correctly.

Any help?

Thanks!

© Stack Overflow or respective owner

Related posts about matlab

Related posts about matlab-figure