How do I create x-axis in boxplot?
14 次查看(过去 30 天)
显示 更早的评论
Hello everyone. I have a vector named A_T. I have 4 different measurement values for each value of this vector. For example, the measurement values in A_T(1,1) are buffer(1,:). I want to plot a boxplot using this data. The x-axis of the chart should be A_T. A boxplot of 4 measurement values should be drawn for each A_T value. So I realized that this is how boxplot actually works.
For this, I wrote a code like this, but they have to coincide with the value of A_T, we are in vector. How can I do this?
for i=1:1:15
hold on
boxplot(buffer(i,:));
end
0 个评论
采纳的回答
dpb
2022-10-2
编辑:dpb
2022-10-2
You've got the orientation of the array backwards to use boxplot effectively; it thinks columns are variables and rows observations. Use the transpose instead...then write the tick labels as desired.
load(websave('A_T.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142745/A_T.mat'));
load(websave('buffer.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142750/buffer.mat'));
boxplot(buffer.')
xticklabels(A_T)
The labels will probably be kinda' hard to read on earlier releases; I don't know when the above angling became builtin behavior (or if it's just a result of the size of the axes in the online platform that does it) but you can set the rotation angle manually if needs be...but with R202b with a figure only about half size of default didn't result in the labels being rotated, it appeared to reduce font size but kept the horizontal orientation.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!