r - Adding and specifying legend to the multiple chart.rolling Correlation plots -


for simplicity, suppose have following zoo object:

x.ts<- structure(c(103.7, 103.2, 103.1, 105.4, 102.1, 103.5, 103.1,  102.6, 102.2, 104.6, -2.1, -1, -3, 2, -1, 1, -1, -1, -1, 0, -25,  -25, -25, -25, -25, -25, -21, -21, -20, -20), .dim = c(10l, 3l ), .dimnames = list(c("1", "2", "3", "4", "5", "6", "7", "8",  "9", "10"), c("a", "b", "c")), index = structure(c(1985, 1985.08333333333,  1985.16666666667, 1985.25, 1985.33333333333, 1985.41666666667,  1985.5, 1985.58333333333, 1985.66666666667, 1985.75), class = "yearmon"), class = "zoo") 

i interested in plotting rolling correlation between each pairs of time series in object. used chart.rollingcorrelation performanceanalytics package , plot charts follow:

par.corr<-par(mfrow=c(1,2), oma = c(1, 1, 1, 1), mar = c(2, 2, 2, 2)) chart.rollingcorrelation(x.ts[, 1, drop=false],                          x.ts[, 1:3, drop=false],                          colorset=rich8equal,legend.loc = "right",                          width=3, main = "a b , c") chart.rollingcorrelation(x.ts[, 2, drop=false],                          x.ts[, c(1,3), drop=false],                          colorset=rich8equal,legend.loc = "right",                          width=3, main = "b , c") mtext("rolling 3 month correlation", side=3, line=-0.3, outer=true, cex=1.2) par(par.corr) 

i following plot:

rolling correlation

i need common legend both charts 1 colour describing each relationship , place bottom of plot. have tried remove legend specification chart.rollingcorrelation's arguments , add plot customised legend there issue that. because every chart in plot has been plotted separately, find 2 different relationships represented same colour. seems need change in way apply function.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -