I intend to produce Matlab figures which are about 8cm wide on a page generated with LaTeX. After resizing the figure the legend appears quite big and the legend covers a lot of my plot. The font size can easily be changed by the "FontSize" property. And I found a thread which shows how the sample lines can be reduced in length. (http://www.mathworks.com/matlabcentral/newsreader/view_thread/155063#389116)
Here is the Problem: After I have resized the legend sample line length I tried to reduce the size of the legend box via the legend's "Position" property. But the size can only be increased but not decreased.
Is there a way to decrease the size of the legend box?
Thanks!
take the black cursor from the toolbar.
left-click on the legend corner
right-click and select 'unlock axex position' or something like this ...
Bodorin
"Daniel Wesemeier" <d.wes...@gmx.de> wrote in message <gdiq5d$t5q$1...@fred.mathworks.com>...
You'll have to post how exactly you used 'Position' to resize the
legend box. I do this all the time and have no problems, so in
principle what you are doing is correct, but the actual implementation
may be wrong.
Thank you for your answers. Somehow I missed the notification. And I found a work around. I resized the Matlab figure twice the size I required and scaled it by half via LaTeX. So I forgot to come back to this thread. But now it turns out this work around has a little troubles when the figure is resized in LaTeX again.
@NZTideMan
I change the Position via get(...,'Position') and set(...,'Position',...).
here is an example:
AllObjects = findobj(gcf);
% Find the legend objects
alllegends = findall(AllObjects,'Tag','legend')
% Identify the legend content
childs = get(alllegends(1),'Children')
n_legent = length(childs);
allmarkers = childs(1:3:n_legent)
alllines = childs(2:3:n_legent)
alltext = childs(3:3:n_legent)
% Readjusting the linest
for it = 1:length(alllines)
xcor = get(alllines(it),'xdata')
leftshift = (xcor(2)-xcor(1))/2;
set(alllines(it),'xdata',[xcor(1) xcor(1)+(xcor(2)-xcor(1))/2]);
end
% Readjusting the text
for it = 1:length(alltext)
pos = get(alltext(it),'Position');
set(alltext(it),'Position',[pos(1)-leftshift pos(2)]);
end
% Change the Position Property
posleg = get(alllegends(1),'Position')
set(alllegends(1),'Position',[posleg(1) posleg(2) posleg(3)-leftshift posleg(4)]);
@Nicolaie Popescu-Bodorin
There is an "Edit Plot" tool and a "Data Cursor" tool. But neither has an "unlock axes option" in its content menu.
Has anyone another hint? Is the a hidden property somewhere that prevent the legend from be resized to small?
(By the way: I am still using Matlab 2007b. Maybe that is the problem.)
one of the (tedious) solutions
x=0:360;
y=sort(rand(size(x)));
line(x,y);
lh=legend('a');
disp('press any key to make legend smaller...');
pause;
set(lh,'units','pixels');
lp=get(lh,'outerposition');
set(lh,'outerposition',[lp(1:2),50,15]);
us
work's! Very nice. So the trick is to change the 'units'. Thanks
Jan.