How to undo only one y axis in xyplot of a zoo object

I'm having problems creating an xyplot zoo object.

I created a simplified example:

z <- zoo(cbind(a=1:4,b=11:14,c=10:13,d=5:8,e=10:7,f=1:4), 1991:1994) 

I use the following code to create a multi-user xyplot:

 numLbl <- 4 xx <- seq(from = min(time(z)), to = max(time(z)), length.out = numLbl) xyplot(z[,c(1,2,4,6)],scales = list(x = list(at = time (z), rot = 90)), layout = c(1,4), aspect = "fill", xlab = "", panel = function (x,y, ...) { panel.abline (v = xx, col = "grey", lty = 3) panel.xyplot(x, y, type = "b", col = 1) }) 

What I would like to do is the y-axis on only one of these panels. I found an appropriate example:

http://r.789695.n4.nabble.com/lattice-limits-in-reversed-order-with-relation-quot-same-quot-td2399883.html

However, I cannot get prepanel to work with my example. I'm new to the bars, and probably something with the panel function I don't understand.

In addition, if there is an easy way to get one of the panels in the form of histograms, and the rest as lines, I will be very grateful for the advice.

Any help is much appreciated!

+4
source share
1 answer

Here is an example of a pane that performs the first task:

 numLbl <- 4 count <- 0 swap <- 3 xx <- seq(from = min(time(z)), to = max(time(z)), length.out = numLbl) xyplot(z[,c(1,2,4,6)],scales = list(x = list(at = time (z), rot = 90)), layout = c(1,4), aspect = "fill", xlab = "", panel = function (x,y, ...) { panel.abline (v = xx, col = "grey", lty = 3) panel.xyplot(x, y, type = "b", col = 1) }, prepanel = function (x,y, ...) { count <<- count + 1 lims <- list(xlim=c(min(x),max(x)), ylim=c(min(y),max(y))); if (swap == count) { lims[[2]] = rev(lims[[2]]); } lims; } ) 
+1
source

Source: https://habr.com/ru/post/1392441/


All Articles