A question about boxplot

  • Follow


Hi everyone!

I have a quick question about the horizontal axis in a boxplot.

Suppose I have two variables X and Y, X=[1,2.3,4.6], for each value of X, I have a group of Y-values, so I want to draw a boxplot in matlab with horizontal axis the X-values.
I use the following code

boxplot(Y);

But the resulting plot only has lables 1,2 3 on its horizontal axis instead of the X-values.
Can I use any method to handle this problem?

Thanks very much for suggestions!
Best wishes,
Zuofeng
0
Reply Zuofeng 5/20/2010 4:59:07 PM

"Zuofeng " <shang@stat.wisc.edu> wrote in message <ht3por$599$1@fred.mathworks.com>...

> I have a quick question about the horizontal axis in a boxplot.
 
> Suppose I have two variables X and Y, X=[1,2.3,4.6], for each value of X, I have a group of Y-values, so I want to draw a boxplot in matlab with horizontal axis the X-values.
> I use the following code
> 
> boxplot(Y);
 
> But the resulting plot only has lables 1,2 3 on its horizontal axis instead of the X-values.
> Can I use any method to handle this problem?

I am not certain, but possibly

boxplot(Y, 'Positions', X)
0
Reply Walter 5/20/2010 6:49:04 PM


>> Suppose I have two variables X and Y, X=[1,2.3,4.6], for each value of X, 
>> I have a group of Y-values, so I want to draw a boxplot in matlab with 
>> horizontal axis the X-values.
>> I use the following code
>>
>> boxplot(Y);
>
>> But the resulting plot only has lables 1,2 3 on its horizontal axis 
>> instead of the X-values.
>> Can I use any method to handle this problem?
....
> boxplot(Y, 'Positions', X)

This will position the boxes, but not change the labels. Try this out:

x = randi(3,100,1);  % random group numbers
v = [1 2.3 4.6];  % desired group values
xx = v(x);  % array of group values
y = xx + randn(size(xx));  % y data
boxplot(y,xx)  % this gives the labels you want
boxplot(y,xx,'position',v)  % this also positions the boxes

-- Tom


0
Reply Tom 5/20/2010 7:48:50 PM

2 Replies
470 Views

(page loaded in 0.876 seconds)

Similiar Articles:













7/23/2012 2:54:20 AM


Reply: