Re: [R] scales argument in bwplot (lattice)

From: Peter Ehlers <ehlers_at_ucalgary.ca>
Date: Tue, 17 May 2011 08:29:59 -0700

On 2011-05-17 06:50, Doran, Harold wrote:
> Suppose I have data such as the following
>
> set.seed(12345)
> tmp<- data.frame(var1 = rnorm(100), var2 = rnorm(100), var3=rnorm(100, 10, 30))
>
> tmp1<- data.frame(vars = with(tmp, c(var1, var2, var3)), type = gl(3, 100))
>
> var3 is on a different scale, but I create the following plot, which looks terrible as a result
>
> bwplot(~ vars|type, tmp1,
> layout = c(1,3),
> )
>
> Of course, I can use the scales = 'free' argument and this looks fine.
>
> bwplot(~ vars|type, tmp1,
> scales = 'free',
> layout = c(1,3),
> )
>
> My real world data are a little tougher to describe, but follow

 > a similar pattern. My question is, is there a way to make the
 > bottom two boxplots to have the *same* scale, but for the top
 > plot to have its own unique scale?

>
> The scales = 'free' argument permits for each plot to have its
 > own scale. Perhaps there is a way to generalize this so only
 > certain plots have a unique scale and all others are on the
 > same scale.

Does this help:

   bwplot(~ vars|type, layout = c(1,3), data=tmp1

     , scales = 'free'
     , xlim=list(c(-3,3), c(-3,3), c(-60,90))
   )

There's a comment on ?xyplot in the scales section:

  "When relation is "free", xlim or ylim can be a list, ..."

Peter Ehlers

>
> Thanks
>
> Harold
>
>
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] lattice_0.19-13
>
> loaded via a namespace (and not attached):
> [1] grid_2.12.0 tools_2.12.0
>
> -
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 17 May 2011 - 15:32:19 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 19 May 2011 - 01:20:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive