add a legend to a boxplot in MATLAB
生活随笔
收集整理的這篇文章主要介紹了
add a legend to a boxplot in MATLAB
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1. 給同組數(shù)據(jù)分類加legend
figure; colors = [1 0 0; 1 0 0; 0 0 1; 0 0.5 0; 0 0.5 0; 0 0.5 0]; x = boxplot(rand(100,6),'Colors',colors); legend('Group A','Group B','Group C')2.給不同組數(shù)據(jù)加legend
box_vars = findall(gca,'Tag','Box'); hLegend = legend(box_vars([8,6]), {'NAME1','NAME2'});findall是找到所有box,按照box的數(shù)量設(shè)置對(duì)應(yīng)box_vars后面的數(shù)值才可以對(duì)應(yīng)到相應(yīng)的box組,要注意數(shù)值的順序是正序還是倒序
總結(jié)
以上是生活随笔為你收集整理的add a legend to a boxplot in MATLAB的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 空间点过程(Point Processe
- 下一篇: LaTeX indicator func