How do I group boxplots by modifying the X locations?

조회 수: 13 (최근 30일)
Ian
Ian 2011년 2월 18일
댓글: Aamir Ansari 2021년 8월 2일
Is there a way to set the 'X' coordinates of several boxplots?
For instance something similar to...
X = [1.2 1.8 3.2 3.8 5.2 5.8];
boxplot(X, Y)
so that it would look like groups of boxplots are set closer together?

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 2월 18일
Perhaps you are looking for the positions option?
X = [1.2 1.8 3.2 3.8 5.2 5.8];
Y = rand(100, 6);
boxplot(Y, 'positions', X, 'labels', X)
  댓글 수: 1
Matt Tearle
Matt Tearle 2011년 2월 18일
how the heck did I not know about that? ::headdesk::

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt Tearle
Matt Tearle 2011년 2월 18일
You can cluster groups together using the 'factorgap' option. Would that do what you want?
% make some fake data
x = rand(200,1);
z = bsxfun(@plus,repmat(x,1,5),-0.1:0.1:0.3);
% standard boxplot
boxplot(z)
% make some grouping labels
g1 = repmat([1 1 1 2 2],200,1);
g2 = repmat('abcab',200,1);
% reshape everything into columns
zv = z(:);
gp1 = g1(:);
gp2 = g2(:);
% boxplot with groupings grouped!
boxplot(zv,{gp1,gp2},'factorgap',[50,0])
  댓글 수: 3
Matt Tearle
Matt Tearle 2011년 2월 18일
Apparently:
>> worldpeace
??? Undefined function or variable 'worldpeace'.
Aamir Ansari
Aamir Ansari 2021년 8월 2일
We can try!!

댓글을 달려면 로그인하십시오.


Ian
Ian 2011년 2월 18일
Yes, the 'positions' one is what i was looking for. Thanks for the responses.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by