From: Gonzalo on
Hello,

In a GUI, I'm copying some objects from a figure to create another figure and print it. The only problem is the legend which in the plotted file shows a huge box unlike in the original figure. Any ideas on how to solve this? See code below. Thanks

OrigFigure = figure;
OrigPlot = plot(x,y);
leg = legend(File);
set(leg,'Interpreter','none','Location','NorthWest','FontSize',7.5);
% Copy features for new plot
originalAxes = gca;
newLeg = leg;
% Create a new invisible figure
newFig = figure(2); set(newFig,'Visible','off');
%Create a copy of the axes
newA = copyobj(originalAxes,newFig);
% Paste features to new plot
newPlot = copyobj(p1,newA);
newLeg = copyobj(newLeg,newFig);
print(newFig,'-djpeg100','graph_name');
From: Mayi DA on
Dear Gonzalo
I met with the same problem as you mentioned, and I am confused of this for a long time.Maybe it is a bug in MATLAB.

mayi
2010-7-19
"Gonzalo " <glpita(a)gmail.com> wrote in message <i0voh0$s37$1(a)fred.mathworks.com>...
> Hello,
>
> In a GUI, I'm copying some objects from a figure to create another figure and print it. The only problem is the legend which in the plotted file shows a huge box unlike in the original figure. Any ideas on how to solve this? See code below. Thanks
>
> OrigFigure = figure;
> OrigPlot = plot(x,y);
> leg = legend(File);
> set(leg,'Interpreter','none','Location','NorthWest','FontSize',7.5);
> % Copy features for new plot
> originalAxes = gca;
> newLeg = leg;
> % Create a new invisible figure
> newFig = figure(2); set(newFig,'Visible','off');
> %Create a copy of the axes
> newA = copyobj(originalAxes,newFig);
> % Paste features to new plot
> newPlot = copyobj(p1,newA);
> newLeg = copyobj(newLeg,newFig);
> print(newFig,'-djpeg100','graph_name');