![yy.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/222984/yy.png)
any way to add legend in bar plot like this?
1 次查看(过去 30 天)
显示 更早的评论
Hi:
is there anyway to add legend of a bar plot like below? i.e. put the bar plot on the left side and the legend on the right side, in one figure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/222981/image.png)
Thanks!
Yu
0 个评论
回答(1 个)
KALYAN ACHARJYA
2019-6-4
编辑:KALYAN ACHARJYA
2019-6-4
See this example
y=[2 2 3; 2 5 6; 2 8 9; 2 11 12];
bar(y,'stacked');
legend('level1','level2','level3','Location','Best','FontSize',8);
![yy.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/222984/yy.png)
2 个评论
KALYAN ACHARJYA
2019-6-4
编辑:KALYAN ACHARJYA
2019-6-4
You can drag (cursor move) and place in figure window. My Matlab v 2018b
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/222990/image.png)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!