How do I create x-axis in boxplot?

조회 수: 10 (최근 30일)
studentmatlaber
studentmatlaber 2022년 10월 2일
댓글: studentmatlaber 2022년 10월 2일
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

채택된 답변

dpb
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개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by