I have a figure file (.fig) that I want to save as a 900 dpi TIFF file.
Normally, if I create the plot myself:
figure;
plot(x,y);
Then the command:
print(gcf,'test.tif','-dpng','-r900');
Would produce the image I want. However, I only have the .fig file and MATLAB does not recognize that plot window by the keyword gcf
. Is there any way to save a high resolution image from a .fig file?
The function gcf
simply returns the current figure handle, so if you've recreated the figure by opening your .fig file with openfig
, it should work. The following example creates two identical TIFF files at a resolution of 900 dpi, one before saving a .fig and one after loading the .fig:
surf(peaks); % Create a surface plot
print(gcf, 'before_save.tif', '-dpng', '-r900'); % Save figure as an image
savefig('peaks.fig'); % Save figure in a .fig file
close(gcf); % Close figure
openfig('peaks.fig'); % Recreate figure from .fig file
print(gcf, 'after_save.tif', '-dpng', '-r900'); % Save new figure as an image