Legend line spacing in R2014b
24 ビュー (過去 30 日間)
古いコメントを表示
In previous versions I was able to control (to some degree) the line spacing in figure legends by changing the PlotBoxAspectRatio property of the legend. I can't seem to do this in R2014b. Anyone know of a new way of doing this?
Basically I can't figure out how to make the legend smaller than some minimum that Matlab seems to determine automatically, and I disagree with how small looks reasonable.
0 件のコメント
回答 (2 件)
Judi
2016 年 4 月 21 日
編集済み: Judi
2016 年 4 月 21 日
In R2015b, I found a hack around this annoying limitation. There appears to be a minimum fontsize that can't be overridden; however, entering a fontsize less than this minimum has the effect of reducing the line-spacing between the legend entries. This solution would only work if you were happy to have the fontsize at the inbuilt minimum. I'm delighted to find this works for my current graph!
A code snippet for my graph is as follows - your mileage may vary:
[legh3,legicons3,legplots3,legs3]=legend([sdplot1(1) sdplot2(1) sdplot3(1)],'Foo','Bar','Baz','Location','southeast');
legh3.Box='off';
legh3.FontSize=4;
legh3.Position=[ 0.81 0.35 0.1286 0.001]
Note that I'm also using the panel add-in, and there may be some interdependencies going on with how font size is treated. http://www.mathworks.com/matlabcentral/fileexchange/20003-panel
Doug Hull
2014 年 11 月 26 日
Here are a variety of changes to legend:
The low level access you had to legend in the past becuase it was an axis is not there anymore. Can you show what you had in the past and what it looks like now so we have a better idea of how to help?
3 件のコメント
Chad Greene
2014 年 11 月 26 日
I noticed this same behavior when you posted your question--
leg.Position(3) = .2*leg.Position(3)
should adjust the width of the legend, but instead it tinkers with the x position. And setting leg.Position(4) too small similarly moves the legend vertically without resizing it.
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!