Boxplot help to get 4 plots into 1 graph of 5.
1 回表示 (過去 30 日間)
古いコメントを表示
I'm trying to compare boxplots in the same graph.
However, my code in placing the data into 4 different boxplots.
figure
subplot(2,2,1)
boxplot(ft_max_data1)
subplot(2,2,2)
boxplot(ft_max_data2)
subplot(2,2,3)
boxplot(ft_max_data3)
subplot(2,2,4)
boxplot(ft_max_data4)
subplot(2,2,5)
boxplot(ft_max_data5)
How would I keep the boxes on the same figure?
0 件のコメント
回答 (1 件)
dpb
2018 年 6 月 29 日
編集済み: dpb
2018 年 6 月 29 日
If you plot multiple boxplot into the same axis, they'll overlay each other for 1:N variables where N is the composite of number in each of the variables passed. In your case I would presume they're probably all the same.
The boxplot as implemented has no provision for a positioning variable along the x-axis; all it has as an option is a grouping variable and (just tried it to see) if one uses it on a matrix, it combines all columns of each group into a single box for the group.
The only way to place multiple boxes on a single axes without them overlaying each other would be something like
boxplot([ft_max_data1 ft_max_data2 ft_max_data3 ft_max_data4 ft_max_data5])
and then use XTickLabel to write identifying text for each of the variables.
Coding would be simpler if you avoided the use of sequentially-numbered named variables and used array or cell array or the like instead so can make effective use of Matlab indexing syntax.
2 件のコメント
dpb
2018 年 6 月 29 日
編集済み: dpb
2018 年 6 月 29 日
" above just gave me a single box,..."
You'll get a box for each column in the input array or one for a vector. I had presumed a column vector array; to make the above work for row vectors you need to write
boxplot([ft_max_data1.' ft_max_data2.' ft_max_data3.' ft_max_data4.' ft_max_data5.'])
or
boxplot([ft_max_data1; ft_max_data2; ft_max_data3; ft_max_data4; ft_max_data5].')
to create a 2D array of variables by column. The first transposes each vector and concatenates them; the second concatenates the row vectors vertically and then transposes that array; same result in the end.
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!