Prev: DIRECT TORQUE CONTROL METHOD USING A MATRIX CONVERTER
Next: Why legend on bar get warning message?
From: Mayi DA on 19 Jul 2010 03:24 Dear Bjoern I met the same problem as you mentioned here, and I am really was confused by this for a long time. In my application, when bar is occurred, MATLAB will give a warning message: Plot emtpy...... I think it is a minor bug in MATLAB. Good luck. mayi 2010-07-19 "Björn " <bjoern.wettergren(a)vonotobel.ch> wrote in message <hjrse2$cqf$1(a)fred.mathworks.com>... > Hi, > > I have a gui with different axes on. I want to copy these axes into Powerpoint and I have found a way using the very helpful tool saveppt. However, in order to use saveppt I have first to copy the desired axes from the GUI into a new Figure. > I have solved that problem by using copyobj. Of Course, here another problem has occured. The legend were not copied well at all, however I have found a solution for this too. I use the following code: > > > START CODE.... > parentAxes is the handle of the axes on the GUI: > > parentFig = get(parentAxes,'parent'); > allChildren = get(parentFig,'children'); > > > copyFigure = figure; > set(gcf,'Units','normalized'); > set(gcf,'ActivePositionProperty','OuterPosition'); > set(gcf,'PaperPositionMode','auto'); > > copyAxes = copyobj(parentAxes,copyFigure); > > set(gca,'Units','Normalized'); > set(gca,'ActivePositionProperty','OuterPosition'); > > oldAxis = axis(parentAxes); > axis(copyAxes,oldAxis); > > oldTitle = get(get(parentAxes,'Title'),'String'); > title(copyAxes,oldTitle); > > oldxgrid = get(parentAxes,'XGrid'); > oldygrid = get(parentAxes,'YGrid'); > > set(copyAxes,'XGrid',oldxgrid); > set(copyAxes,'YGrid',oldygrid); > > parentFig = get(parentAxes,'parent'); > allChildren = get(parentFig,'children'); > > childrenAxes = findall(allChildren,'Type','axes'); > > for m= 1:length(childrenAxes) > > switch get(childrenAxes(m),'Tag') > case 'legend' > > legendData = get(childrenAxes(m),'UserData'); > location = get(childrenAxes(m),'Location'); > legend(legendData.lstrings,'location',location); ********** > end > end > > set(copyFigure,'position',[0 0 1 1]); > > P = get(copyAxes,'position'); > P(4) = 0.8; > > titleHandle = get(copyAxes,'Title'); > set(titleHandle,'fontsize',20); > > saveppt2('powerpointCop','Fig',copyFigure) > > close(copyFigure) > END CODE > > > HOWEVER, now I have the next problem: > The AXES i want to copy contains either a normal plot or a stem-plot. It works very well if the axes contains a normal plot, but when it contains a stem i cannot insert the legend (I marked that line with ****). > I think it might be a matlab bug, because I just cannot find where it can gor wrong. > > The variables location and legendData.lstrings conatin the correct values. Also if i plot a stem plot from the workspace everything works fine, but here i get the error message: > > Warning: Plot empty. > > ANY IDEAS???? I have been sitting with this ridiculously simple task (exporting a figure from the gui to powerpoint) for a week now. I find it very strange that MATLAB has not a built in function for this. > > I am very thankful for any hints and tips.... > > Thanks a lot, regards > Björn
|
Pages: 1 Prev: DIRECT TORQUE CONTROL METHOD USING A MATRIX CONVERTER Next: Why legend on bar get warning message? |