[R] setting yaxis in logscale
Duncan Mackay
dulcalma at bigpond.com
Wed Feb 12 06:53:56 CET 2014
I have not received my OP email yet or the gremlins of filters have stepped
in
I had a quick look at the site but did not find anything
It is a case of modifying the scales argument
dput(xy)
structure(list(x = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L,
1L, 2L, 3L, 4L, 5L), y = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L), groups = c("A", "A", "A", "A", "A",
"B", "B", "B", "B", "B", "C", "C", "C", "C", "C")), .Names = c("x",
"y", "groups"), row.names = c(NA, -15L), class = "data.frame")
xyplot(y~x|groups,xy,
scales = list(x = list(relation = "free",
at = rep(list(1:5),3),
labels = list(c("Wk 1\nXXX", paste("Wk",
2:5)),
c("Wk 2\nXXX",
paste("Wk", 2:5)),
c("Wk 3\nXXX",
paste("Wk", 2:5)) ) ))
)
The x axis labels are not a trivial thing. See
https://stat.ethz.ch/pipermail/r-help/2007-May/132818.html
This gives a little more control over things.
And this is it below
library(grid)
myXlabGrob <-
function(...) ## ...is lab1, lab2, etc
{
## you can add arguments to textGrob for more control
## in the next line
labs <- lapply(list(...), textGrob)
nlabs <- length(labs)
lab.heights <-
lapply(labs,
function(lab) unit(1, "grobheight", data = list(lab)))
lab.layout <-
grid.layout(ncol = nlabs, nrow = 1,
heights = do.call(max, lab.heights),
widths = unit(1, "null"),
respect = TRUE)
lab.gf <- frameGrob(layout = lab.layout)
for (i in seq_len(nlabs))
{
lab.gf <- placeGrob(lab.gf, labs[[i]], row = 1, col = i)
}
lab.gf
}
xyplot(1:9 ~ 1:9 | gl(3, 1, 9),
layout = c(3, 1),
xlab =
myXlabGrob('Trial number',
'Subject number',
'Experimental condition'),
strip = FALSE)
If you want to change the height for the labels I think you can change the
heights in grid.layout
There
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Winsemius
Sent: Wednesday, 12 February 2014 12:09
To: juliana Arruda de Matos
Cc: r-help at r-project.org
Subject: Re: [R] setting yaxis in logscale
On Feb 11, 2014, at 12:26 PM, juliana Arruda de Matos wrote:
> Hi all,
>
>
>
> I´ve been trying hard to set up the yaxis in log scale as the Figure 3 in
the article below, but I couldn´t find out how to do it. Could anybody help
me?
>
>
>
> http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0041936
>
I'm pretty sure you can find a worked example using the lattice package at
Deepayan Sarkar's Lattice website. You would probably find a worked example
of setting up a datset which your posting fialed to include.
>
> [[alternative HTML version deleted]]
Please read the Posting Guide.
______________________________________________
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.
David Winsemius
Alameda, CA, USA
______________________________________________
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.
More information about the R-help
mailing list