| Hui Song 2007-08-23, 7:19 pm |
| Hi Barry,
I think it is not a good idea to adjust the orignal code of
legend. Her eis a solution. Hope it can help.
Just give an example on line case:
Case actually the legend is just an axes object.
First setp is to find the legend. of course you can get the
when you create it.
LegendHandle = legend(...) ;
Or using findobj(gcf, 'Type', 'axes'); to find it.
Second setp is to find the children
Children = get(LegendHandle, 'Children') ;
Fot line case, the number of childre always n*3, n is the
number of line legend. In another word (every 3 objects
create one lenged).
Third setp is to recogonize the children(every 3 objects).
Using get(Children(Index)) ;
The first child is the marker.
The second one is the line
The last one is the text
Third setp is to rescale the line length and the marker
position. Using get and set:
XData = get(Children(1), 'XData') ;
XScale = XData(2) - XData(1) ;
XData(2) = XData(1) + XScale / 2 ; % half location
set(Children(1), 'XData', XData) ;
and do the same thing to the line and the text.
You can control the legend objects very flexible.
"Barry Canton" <bcanton.no.spam@mathworks.com> wrote in
message <faksf5$7al$1@fred.mathworks.com>...
> Hi,
> I need to plot a legend in a small area of an axes. I
would
> like to use more of the legend box for the text strings
and
> less for the line samples so my fontsize isn't tiny.
>
> Is it possible to reduce the fraction of the legend box
that
> is used for the line samples? This doesn't appear to be
set
> in legend.m and I couldn't figure out what function is
> called to draw the contents of the legend box.
>
> Many thanks for any advice,
>
> Barry
|