From: Marc Schwartz (via MN) <mschwartz_at_mn.rr.com>

Date: Fri 30 Sep 2005 - 00:34:06 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Sep 30 00:37:01 2005

Date: Fri 30 Sep 2005 - 00:34:06 EST

On Thu, 2005-09-29 at 15:28 +0200, Karin Lagesen wrote:

> "Petr Pikal" <petr.pikal@precheza.cz> writes:

*>
**> > Hi Karin
**> >
**> > I did not have seen any answer for your question yet so here is a
**> > try.
**> >
**> > I gues you want the horizotal layout or your boxplot.
**> >
**> > boxplot(split(rnorm(30), rep(1:3, each=10)), horizontal =T,
**> > names=letters[1:3])
**> >
**> > boxplot(split(rnorm(30), rep(1:3, each=10)), horizontal =T,
**> > names=c(NA,"b",NA))
**>
**> These look like the plots I want, yes. However, is there a way of
**> locking the x-axis? When I do these several times in a row, the range
**> of the x axis moves with the data being plotted. If I set xlim in the
**> boxplot command, it makes no difference what so ever.
*

That's because when you use 'horizontal = TRUE' in boxplot(), the x and y axes are rotated. Thus you need to set 'ylim' and not 'xlim', where ylim is the range of values in your data irrespective of the axis orientation.

This is done in bxp(), which is the actual function doing the plotting for boxplot(). In bxp(), there is the follow code snippet:

if (horizontal) plot.window(ylim = c(0.5, n + 0.5), xlim = ylim, log = log) else plot.window(xlim = c(0.5, n + 0.5), ylim = ylim, log = log)

Note in the first case, that the xlim value for plot.window() is set to the ylim value passed from boxplot() or from bxp(), if called directly.

So, the above examples by Petr should be something like:

boxplot(split(rnorm(30), rep(1:3, each=10)), horizontal = TRUE,

names=letters[1:3], ylim = c(-4, 4))

boxplot(split(rnorm(30), rep(1:3, each=10)), horizontal =TRUE,

names=c(NA,"b",NA), ylim = c(-4, 4))

**HTH,
**
Marc Schwartz

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Sep 30 00:37:01 2005

*
This archive was generated by hypermail 2.1.8
: Sun 23 Oct 2005 - 17:59:34 EST
*