From: tstmwind on 30 Oct 2009 15:14 Hello, I have a GUI that I've generated that gives options for different types of plots that when selected shows up in the specified uipanel. However, for one particular plot, when I hit the "Save" button, it will not save in *.fig format. However, it will save in *.png format. I do not have this problem with any of the other plots. Can anyone tell me what's going on here? I get the following error when trying to save in *.fig format: *************** ??? Error using ==> getProxyValueFromHandle at 15 Input must be a valid handle. Error in ==> plotedit at 91 [varargout{1:nargout}] = feval(args{:}); Error in ==> specgraph.barseries.preserialize at 10 peerVals = plotedit({'getProxyValueFromHandle',hPeers}); Error in ==> hgsave at 149 olddata{i}(2*k-1:2*k) = {hh,preserialize(hh)}; Error in ==> saveasfig at 7 hgsave( h, name ); Error in ==> saveas at 126 feval( ['saveas' format], h, name ) Error in ==> FrequencyGUI>SavePlot_Callback at 1093 saveas(newfig,[pathname,'figures\',handles.imgname(1:end-4)],'fig') Error in ==> gui_mainfcn at 96 feval(varargin{:}); Error in ==> FrequencyGUI at 45 gui_mainfcn(gui_State, varargin{:}); Error in ==> @(hObject,eventdata)FrequencyGUI('SavePlot_Callback',hObject,eventdata,guidata(hObject)) ??? Error while evaluating uicontrol Callback ***************** I use the following code to setup the axes in the uipanel, plot the data, and save the plot: ***************** %Create axes upon opening the GUI function FrequencyGUI_OpeningFcn(hObject, eventdata, handles, varargin) handles.ax1=axes('Units','inches','Position',[0.5,3,5,2],'Parent',handles.PlotPanel3); handles.ax2=axes('Units','inches','Position',[5,3,2,2],'Parent',handles.PlotPanel3); handles.ax3=axes('Units','inches','Position',[0.5,0.5,5,2],'Parent',handles.PlotPanel3); handles.ax4=axes('Units','inches','Position',[5,0.5,2,2],'Parent',handles.PlotPanel3); % Choose default command line output for FrequencyGUI handles.output = hObject; % Update handles structure guidata(hObject, handles); %Plot the data function Plot_Callback(hObject, eventdata, handles) PlotVal=get(handles.PlotOption,'Value'); x=handles.x; y=handles.y; pdfx=handles.pdfx; pdfy=handles.pdfy; bins=handles.bins; t=handles.t; switch case 1 %plot 1 cla(handles.ax1) plot(handles.ax1,t,x) set(handles.ax1,'XLim',[0,3600],'XTick',0:300:3600,'YLim',...[bins(1),bins(end)]) %plot 2 cla(handles.ax2) barh(handles.ax2,bins,pdfx,'b','EdgeColor','none','BarWidth',1) set(handles.ax2,'YLim',[bins(1),bins(end)],'YTickLabel','') cla(handles.ax3) plot(handles.ax3,t,y) set(handles.ax3,'XLim',[0,3600],'XTick',0:300:3600,'YLim',[bins(1),bins(end)]) cla(handles.ax4) barh(handles.ax4,.bins,pdfy,'b','EdgeColor','none','BarWidth',1) set(handles.ax4,'YLim',[bins(1),bins(end)],'YTickLabel','') handles.position=[2,2,8,5.5]; handles.imgname='Image'; handles.panel=handles.PlotPanel3; case 2 %etc. end guidata(hObject,handles); %save the plot function SavePlot_Callback(hObject, eventdata, handles) pathname=handles.pathname; position=handles.position; panel=handles.panel; subplots=findobj(panel,'Type','axes'); newfig=figure('Units','inches','Position',position); for k=1:length(subplots) copyobj(subplots(k),newfig); end checkdir(pathname,'figures'); set(newfig,'PaperPositionMode','manual') set(newfig,'PaperUnits','inches') set(newfig,'PaperPosition',position) saveas(newfig,[pathname,'figures\',handles.imgname(1:end-4)],'fig') %here is where *.fig does not work and *.png does %hgsave and print also generate errors when attempted *************
|
Pages: 1 Prev: how to overcome this distance matrix to large Next: Ternary Operator |