Re: [R] log scale y axis ticks control on boxplots

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Tue 28 Feb 2006 - 16:21:13 EST

On Mon, 2006-02-27 at 23:08 +0100, Thomas Hoffmann wrote:
> Hey R Users
>
> I like to control the ticks and labels in a boxplot as described for a
> xyplot below (thread in maillinglist in may 2003). Does anybody knows
> how it works?
>
> Thanks in advance
> Thomas
>
> Thread from May 2003
> (http://tolstoy.newcastle.edu.au/R/help/03a/5604.html)
>
> Hello R Users!
>
> I'm using lattice to produce some graphs with logaritmic y-scales. I use
> the command
>
> xyplot(hits ~ c(1:1024), data=eichData, type="S", scales=list(y =
> list(log=10)))
>
> to create the plot. This is fine, except for the automatically choosen
> tick marks. I'd like to have a major tick at the 10^n location and minor
> ticks in between which correspond with the native variable. To get this
> working I have to use at and label like
>
> labl <- rep("", 30)
> labl[1] <- "1"; labl[10] <- "10"; labl[19] <- "100"; labl[28] <- "1000";
> nums <- c(1:10, seq(20,100, 10), seq(200, 1000, 100))
> xyplot(hits ~ c(1:1024), data=eichData, type="S", scales=list(y =
> list(log=10, at=nums, labels=labl)))

It's not entirely clear whether you want this using bwplot() or boxplot(). So...here are examples using both:

  library(lattice)
  x <- 1:1000
  labl <- rep("", 28)

  labl[1] <- "1"
  labl[10] <- "10"
  labl[19] <- "100"
  labl[28] <- "1000"

  nums <- c(1:10, seq(20, 100, 10), seq(200, 1000, 100))   bwplot(x, log = "x",

         scales = list(x = list(log = 10, at = nums, labels = labl)))

  x <- 1:1000
  boxplot(x, log = "y", yaxt = "n")
  labl <- rep("", 28)

  labl[1] <- "1"
  labl[10] <- "10"
  labl[19] <- "100"
  labl[28] <- "1000"

  nums <- c(1:10, seq(20, 100, 10), seq(200, 1000, 100))   axis(2, at = nums, label = labl, las = 2)

Is either one of those what you are looking for?

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 Tue Feb 28 16:31:02 2006

This archive was generated by hypermail 2.1.8 : Tue 28 Feb 2006 - 18:08:51 EST