Quantcast

log scale y axis ticks control on boxplots

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

log scale y axis ticks control on boxplots

Thomas Hoffmann
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)))

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: log scale y axis ticks control on boxplots

Marc Schwartz (via MN)
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...