**Matlab no longer allows access to the elements within a legend, so this code will not work from Matlab circa-2014 onwards.**
legendshrink reduces the amount of horizontal space taken up by a figure legend by reducing the length of lines. (Best results when the legend box is off.)
This is important for small plots because the size of the lines is
constant irrespective of the physical size of the figure. Only works
for vertical legends, for now.
Thanks for the code. I have a vertical legend in the upper right corner with two elements within the legend. The code is shrinking one of the elements as described but upon the second loop, I get the following error:
Error using hg.hggroup/get
The name 'XData' is not an accessible property for an instance of class 'hggroup'.
Error in legendshrink (line 114)
linepos = get(cch(ii),'XData');