http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266
MATLAB Central Newsreader  Change length of legend line sample?
Feed for thread: Change length of legend line sample?
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Fri, 12 Mar 2010 09:54:05 +0000
Change length of legend line sample?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266#725749
drgz
Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?<br>
<br>
When I search in the product help I find examples for changing almost everything else, but can't find anything about this.

Fri, 12 Mar 2010 10:06:57 +0000
Re: Change length of legend line sample?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266#725753
Walter Roberson
drgz wrote:<br>
> Is there any way in MATLAB to reduce the length of the line sample, as <br>
> it is with i.e. Gnuplot (set key samplen 'sample length')?<br>
> <br>
> When I search in the product help I find examples for changing almost <br>
> everything else, but can't find anything about this.<br>
<br>
Yes, it is _possible_ to change it, but there probably is no special <br>
control for the length (I could figure out if there is, but it's 4 am <br>
and I have to sleep.)<br>
<br>
Legends in matlab are implemented by adding a second axis to the figure. <br>
The lines and text are then placed within that axis. Find that second <br>
axis and you can find its child line objects, and you can then change <br>
their XData properties to change the length and positions of the lines. <br>
Or more simply, make the axis smaller by changing its Position <br>
properties, and then set the XLim property of the axis so that the <br>
lefthand side of the lines are cut off. Saves you altering the <br>
individual lines, and if you were wanting the lines shorter you were <br>
probably wanting to change the axis Position anyhow (either because you <br>
wanted a smaller legend box or because you wanted longer titles and it <br>
would be a nuisance to also change the Position properties of all of the <br>
text() objects to match a shorter line length...)

Fri, 12 Mar 2010 12:03:05 +0000
Re: Change length of legend line sample?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266#725790
Sadik
By the way, I am using Matlab 7, so you had better check if it is really the second element of linesInPlot, that is if the handle is given by linesInPlot(2).<br>
<br>
<br>
"drgz " <syrehue@hotmail.com> wrote in message <hnd2vt$6r$1@fred.mathworks.com>...<br>
> Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?<br>
> <br>
> When I search in the product help I find examples for changing almost everything else, but can't find anything about this.

Fri, 12 Mar 2010 12:09:05 +0000
Re: Change length of legend line sample?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266#725794
Sadik
I am sorry, it seems that my message did not show up for some reason. I am writing again:<br>
<br>
An example:<br>
<br>
plot(1:10)<br>
legend('a')<br>
linesInPlot = findobj('type','line'); % linesInPlot(2) is the handle to that line<br>
get(linesInPlot(2),'XData') % returns 0.1231 0.7385<br>
set(linesInPlot(2),'XData',[0.1231 0.4]) % so that new length < 0.5*previous<br>
<br>
Best.<br>
<br>
<br>
<br>
<br>
"Sadik " <sadik.hava@gmail.com> wrote in message <hndahp$3ij$1@fred.mathworks.com>...<br>
> By the way, I am using Matlab 7, so you had better check if it is really the second element of linesInPlot, that is if the handle is given by linesInPlot(2).<br>
> <br>
> <br>
> "drgz " <syrehue@hotmail.com> wrote in message <hnd2vt$6r$1@fred.mathworks.com>...<br>
> > Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?<br>
> > <br>
> > When I search in the product help I find examples for changing almost everything else, but can't find anything about this.

Fri, 12 Mar 2010 17:27:05 +0000
Re: Change length of legend line sample?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/276266#725877
drgz
"drgz " <syrehue@hotmail.com> wrote in message <hnd2vt$6r$1@fred.mathworks.com>...<br>
> Is there any way in MATLAB to reduce the length of the line sample, as it is with i.e. Gnuplot (set key samplen 'sample length')?<br>
> <br>
> When I search in the product help I find examples for changing almost everything else, but can't find anything about this.<br>
<br>
Thanks a lot to both of you! Hopefully there will an easier way of doing this in the future ;)<br>
<br>
Greets!