Why am I unable to save my plot correctly in MATLAB 7.0 (R14)?

2 views (last 30 days)
When I save a contour plot in MATLAB 7.0 (R14), the axes does not maintain its XLim and YLim settings when the FIG-file is reloaded. For example, if I run the following code:
%create contour
contour(peaks)
% set XLim and YLim
set(gca,'XLim',[-5 55],'YLim',[-5 55])
% save the figure
saveas(gcf,'test')
% open the figure
openfig('test')
Then the XLim and YLim have the automatically set limits, rather than the limits I set manually.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that MATLAB saves the axes limits.
Currently, to work around this issue, try setting the 'NextPlot' property of the axes to 'Add' until after the figure is saved:
%create contour
contour(peaks)
% set XLim, YLim properties
set(gca,'XLim',[-5 55],'YLim',[-5 55]);
% set the NextPlot property and save the figure
npp = get(gca,'NextPlot')
set(gca,'NextPlot','add')
saveas(gcf,'test')
% restore the old NextPlot value
set(gca,'NextPlot', npp);
% open the figure
openfig('test')

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!