boxplot labels from numbers and strings
古いコメントを表示
Hello, How can I use both a vector of numbers and a string to label different boxplots in one graph? if a, b are vectors then something of this sort doesn't work boxplot([a,b],'labels',[1,'b'])
Thank you, Stefka
回答 (1 件)
_"[1,'b']"_ doesn't work outside of *boxplot*, either; you can't juxtapose character and numeric data in a vector. Use cell strings instead...
boxplot([a b],'labels',{'1';'b'})
Or more generically, num2str(v) if v is a value returns the character representation rather than hardcoding it.
ADDENDUM
N=10; % a number of points to illustrate...
a=randn(5,N); % rand data to plot for N observations...
boxplot(a,num2str([1:N].','Obs%2d');
The only "trick" above is to be sure to orient the numeric vector as a column; that's the hint to num2str to put each element on a separate row; otherwise the all get run together on a single line.
Any other of a multitude of ways can be used to generate the label strings as long as end up with either a column character array or a cellstr array.
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!