Aligning multiple xts time series plots

I have an xts object with 4 columns. The first 3 columns represent the middle and lower and upper confidence limits for the fraction. 4th column is the sample size. Since the scales are different, I thought it would be advisable to build the first 3 columns on one chart and build a chart on a separate chart right below it. Any suggestions on how to do this?

Here is the code to create the xts object, which is similar to the one I have:

startTime = Sys.time() n = 10 d = seq(startTime,startTime+n*24*60*60,by="1 day") a = sample(10000,length(d),replace=TRUE) p = runif(length(d)) l = p/2 u = p+(p+1)/2 x= xts(p,d) x = cbind(x,l,u,a) colnames(x) = c("prop","low","high","size") 
+4
source share
1 answer

This is easy to do if you use plot.zoo . Something like this will let you get started:

 library(xts) data(sample_matrix) x <- as.xts(sample_matrix) plot.zoo(x, screens=c(1,1,1,2)) 

There are several examples in ?plot.zoo ; Remember to check them out.

+10
source

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


All Articles