From: Zuofeng on
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
From: Walter Roberson on
"Zuofeng " <shang(a)stat.wisc.edu> wrote in message <ht3por$599$1(a)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)
From: Tom Lane on
>> 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