[R] xyplot: several plots in one creates y-scale problem
Duncan Mackay
mackay at northnet.com.au
Mon Jan 4 08:50:13 CET 2010
Hi
As you did not provide an example as per posting guide here is one dataset
cobbled from zoo help.
It is fairly rough but is optioned up to give you an idea.
The legend takes is cues from trellis.par.set() and you can set this for
the plot by using par settings
It makes use of strip.left which gives you more space for the panel area
rather than taken up by horizontal strips.
require(zoo)
require(lattice
z1 <- matrix(rep(1:12,4)+round(rnorm(48),1),12,4,
dimnames=list(1:12,paste("C",1:4) ) )
z2 <-zoo(z1, as.Date("2003-01-01") + 0:11)
xyplot(z2,
auto.key = list(text=paste(names(z2)), points = FALSE, lines = T,
space = "bottom"),
par.settings = list(superpose.line = list(col = rep(1,7,
lty = rep(1, 7)) )),
strip.left = strip.custom(factor.levels = paste("C",1:4),
par.strip.text = list(cex = 0.75),
horizontal = FALSE),
strip = F,
scales=list(x=list(at=as.numeric(as.Date("2003-01-01") +
0:11)[seq(1,12,2)],
labels=paste(format(c(as.Date("2003-01-01") +
0:11)[seq(1,12,2)],"%d %b"))),
y = list(alternating = T,
limits = list(c(0,12),c(0, 12), c(0, 12),
c(0, 15)) ,
relation = "free",
rot = 0)
) ,
col=1
)
HTH
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email Home: mackay at northnet.com.au
At 09:09 3/01/2010, you wrote:
>Hello,
>
>I've been looking for a solution to this problem for some time now but
>I seem unable to solve it.. so this is the case: I want to plot 4 time
>series in the same graph using xyplot(). When I do this with
>
>xyplot(mydata[,2]+mydata[,3]+mydata[,4]+mydata[,5] ~ mydata[,1], data
>= mydata,
> type = "l",
> auto.key = list(space="right", lines = T, points = F),
> par.settings = simpleTheme(lty = c(1,2,3,4))
> )
>
>I get a graph where all lines are "maximized" to cover the entire y-
>scale width. I.e., they are use their own scale independent of each
>other (my data has some columns that are one magnitude smaller than
>the others). How do I force them all to use the same y-scale?
>
>I found this thread:
>http://n4.nabble.com/superimposing-xyplots-on-same-scale-td905525.html,
>but I'm not really sure what is going on there. Any ideas?
>
>/J
>
>______________________________________________
>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