Walter Roberson <roberson@hushmail.com> wrote in message <hnd65i$i9e$1@canopus.cc.umanitoba.ca>...
> Hermano Cappa wrote:
> > Hello,
> >
> > I wrote a program with a GUI. I also made a button for saving the plots
> > as a *.fig file. When I open the saved *.fig file, Matlab opens the
> > import wizard (size= 1267x1894x3 and the class= uint8). When I click on
> > the finish button the data is loaded in the workspace.
> > The figure I saved was a polar plot. What can be the problem? The size
> > of the matrix?
>
> Problem with the way you save the file, possibly. Could you show us the
> relevant lines of code to save the plots to file?
function save_plot_Callback(hObject, eventdata, handles)
savePlotWithinGUI(handles.axes_for_plot);
function savePlotWithinGUI(axesObject, legendObject)
%this function takes in two arguments
%axesObject is the axes object that will be saved (required input)
%legendObject is the legend object that will be saved (optional input)
%stores savepath for the phase plot
% [filename, pathname] = uiputfile({ '*.emf','Enhanced Meta File (*.emf)';...
% '*.bmp','Bitmap (*.bmp)'; '*.fig','Figure (*.fig)'}, ...
% 'Save picture as','default');
[filename, pathname] = uiputfile(...
{ '*.fig','Figure (*.fig)';...
'*.eps','Encapsuladed Postscript (*.eps)';...
'*.png','Portable Network Graphics (*.png)';...
'*.emf','Enhanced Meta File (*.emf)';...
'*.pdf','Portable Document Format (*.pdf)'}, ...
'Save picture as','untitled');
% {'*.m;*.fig;*.mat;*.mdl','MATLAB Files (*.m,*.fig,*.mat,*.mdl)';
% '*.m', 'M-files (*.m)';...
% '*.fig','Figures (*.fig)';...
% '*.mat','MAT-files (*.mat)';...
% '*.mdl','Models (*.mdl)';...
% '*.*', 'All Files (*.*)'},...
% 'Save as');
%if user cancels save command, nothing happens
if isequal(filename,0) || isequal(pathname,0)
return
end
%create a new figure
newFig = figure;
set(newFig,'Visible','off');
%get the units and position of the axes object
axes_units = get(axesObject,'Units');
axes_pos = get(axesObject,'Position');
%copies axesObject onto new figure
axesObject2 = copyobj(axesObject,newFig);
%realign the axes object on the new figure
set(axesObject2,'Units',axes_units);
set(axesObject2,'Position',[15 5 axes_pos(3) axes_pos(4)]);
%if a legendObject was passed to this function . . .
if (exist('legendObject'))
%get the units and position of the legend object
legend_units = get(legendObject,'Units');
legend_pos = get(legendObject,'Position');
%copies the legend onto the the new figure
legendObject2 = copyobj(legendObject,newFig);
%realign the legend object on the new figure
set(legendObject2,'Units',legend_units);
set(legendObject2,'Position',[15-axes_pos(1)+legend_pos(1) 5-axes_pos(2)+legend_pos(2) legend_pos(3) legend_pos(4)] );
end
%adjusts the new figure accordingly
set(newFig,'Units',axes_units);
set(newFig,'Position',[15 5 axes_pos(3)+30 axes_pos(4)+10]);
%saves the plot
if(strcmp(filename(end-2:end),'pdf'));
save2pdf([pathname filename],newFig,600);
else
harm = 3;
saveas2(newFig,[pathname filename]);
end
%closes the figure
close(newFig)
|