List of 2
?$ ticks:List of 1
? ..$ at: int [1:10] 1 2 3 4 5 6 7 8 9 10
?$ tick :List of 1
? ..$ at: chr "bar"
I don't know if there is a good argument for this assignment to work
at all (other than that NULL and an empty list are conceptually
equivalent), but it is what it is.
This is why I tend to set options(warnPartialMatchDollar = TRUE). In
this case it would give you an inaccurate warning, but at least it
will give you a warning.
As for the range of the scales, these are determined by 'ylim' and
'prepanel', so you would need to specify one of these.
As you are using scales$axs = "i", you can simply provide ylim = c(0,
NA), which forces the lower limit to 0, and lets the upper limit be
decided as usual.
For finer control, you can specify a prepanel function, e.g.,
prepanel = function(x, y, ...) list(ylim = c(0, max(y)))
Hope this helps,
Best,
-Deepayan
Thank you for your help.
Laurent
??--------------------------o<----------------------------------------------->o-----------------------------------------
library(lattice)
library(zoo)
##
## Rq : mydata is a zoo object
##
mydata <- structure(c(0.190991684047867, 0.186639474048368,
0.188562286982088,
???????????? 0.187781290093149, 0.188242724296645, 0.190412570465429,
0.188922969182772,
???????????? 0.194037520889193, 0.191973884842229, 0.197032138922638,
1.03204611806177,
???????????? 1.02831610106898, 1.0280323738983, 1.03595907392095,
1.03316162925952,
???????????? 1.04755124287765, 1.04403986225312, 1.05686325668364,
1.04672225664295,
???????????? 1.05462971668107), dim = c(10L, 2L), dimnames =
list(c("f1",
????????? "f1", "f1", "f1", "f1", "f1", "f1", "f1", "f1", "f1"),
c("col1","col2"))
????????? , index = c(1.27904891967773, 1.27909898757935,
1.27915000915527
?????? , 1.27920007705688, 1.2792489528656, 1.27929902076721,
1.27935004234314
?????? ,1.27939891815186, 1.27944993972778, 1.27950000762939),
class =
"zoo")
options(digits=17)
yscale.components.n.ticks <- function(lim,...){
?? ans <- yscale.components.default(lim = lim,...)
?? ylim <- lim
?? ## I want to start from 0
?? ylim <- c(0,max(lim))
tick.at <http://tick.at> <- pretty(ylim, n=10, min.n = 9)
??? cat("lim yscale : ",ylim,"\n")
?? mylabels_y <- formatC( tick.at <http://tick.at>
????????????????????????? , format = "f"
????????????????????????? , digits=3
????????????????????????? , width=9
????????????????????????? ,flag=" ")
?? print(cbind( mylabels_y = mylabels_y, tick.at_y = tick.at
<http://tick.at>))
?? ans$left$tick$at <- tick.at <http://tick.at>
?? ans$left$labels$at <- tick.at <http://tick.at>
?? ans$left$labels$labels <- mylabels_y
?? ans
}
xscale.components.n.ticks <- function(lim, ... ){
?? ans <- xscale.components.default(lim = lim,...)
tick.at <http://tick.at> <- pretty(lim,20,9)
?? mylabels_x <- formatC( tick.at <http://tick.at>
????????????????????????? , format = "f"
????????????????????????? , digits=6
????????????????????????? , width=9
????????????????????????? , flag=" ")
?? print(cbind( mylabels_x = mylabels_x, tick.at_x = tick.at
<http://tick.at>))
?? ans$bottom$tick$at <- tick.at <http://tick.at>
?? ans$bottom$labels$at <- tick.at <http://tick.at>
?? ans$bottom$labels$labels <- mylabels_x
?? ans
}
# to see the x values
time(mydata)
gr <- xyplot(? mydata
??????????????? , main = "title"
??????????????? , layout = c(1,2)
??????????????? , pch = 20
??????????????? , panel = function(...) {
????????????????? ylim <- current.panel.limits()$ylim
????????????????? xlim <- current.panel.limits()$xlim
????????????????? ## I create here the same ticks that those created
????????????????? ##? in xscale.components and yscale.components
????? ???????? ? ylim <- c(0,max(ylim))
???????????????? cat("ylim panel : ",ylim,"\n")
y.tick.at <http://y.tick.at> <- pretty(ylim,10,9)
???????????????? print(cbind(y.tick.at.panel= y.tick.at
<http://y.tick.at>))
x.tick.at <http://x.tick.at> <- pretty(xlim,20,9)
???????????????? panel.abline( h = y.tick.at <http://y.tick.at>, v
= x.tick.at <http://x.tick.at>, col =
"lightgrey")
????????????????? panel.xyplot(...)
??????????????? }
##?????????????? , ylim = c(0,1.5)
??????????????? , scales = list(
????????????????? y= list(?? relation = "free"
?????????????????????????? , axs="i"
?????????????????????????? , rot = 45
?????????????????????????? ),
????????????????? x = list(
????????????????????????????? axs="i"
??????????????????????????? , rot = 90
?????????????????????????? )
??????????????? )
??????????????? , yscale.components = yscale.components.n.ticks
??????????????? , xscale.components = xscale.components.n.ticks
)
print(gr)
--
Cet e-mail a ?t? v?rifi? par le logiciel antivirus d'Avast.
www.avast.com <http://www.avast.com>