How can I change the thickness of a bar within the legend of a plot in MATLAB 7.5 (R2007b)?

3 views (last 30 days)
I am generating a plot with a legend in MATLAB. I would like to modify the thickness of the bar displayed in the legend.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
The thickness of a bar inside a legend can be changed by modifying the patch object itself. This can be accomplished as follows:
1. Create a BAR plot with a legend:
a=rand(1,100);
bar(a);
l=legend('foo');
2. Obtain and modify the 'xData' and 'yData' property of the legend patch object:
h=findobj(l,'type','patch');
set(h,'ydata',[0.,0.5,0.5,0.3,0.3],'xdata',[0.2,0.2,0.4,0.4,0.2]);

More Answers (0)

Tags

Products


Release

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!