[R] Reproducing a 3d yield curve plot from New York Times

matt at considine.net matt at considine.net
Thu Jun 4 22:16:04 CEST 2015


I am trying to closely reproduce the 3d yield curve chart that showed up 
in the New York Times in March, as seen here
   
http://www.nytimes.com/interactive/2015/03/19/upshot/3d-yield-curve-economic-growth.html?ref=economy&abt=0002&abg=0

Working with chartSeries3d0 gets me close, but not quite there :

library(xts)

chartSeries3d0 <-
   function(Z, theta=30, r=10, col=c("yellow","red"), smoother=1, 
border=NA, shade=.3,
            phi=10,scale=FALSE,expand=1,lphi=20,box=FALSE,  #mattc
            ltheta=20,  x.cex=.75, srt=0,...) {
     cnames <- colnames(Z)
     yred <- colorRampPalette(col)
     par(mar=c(3,1,1,1))
     time.axis <- axTicksByTime(Z,ticks.on="years",k=5)
     if(smoother > 1)
       Z <- as.xts(t(apply(Z,1,function(x) spline(as.vector(coredata(x)), 
n=smoother*length(x))$y)))
     pm <- persp(z=Z,
                 x=(1:NROW(Z))/length(time.axis),
                 y=(1:NCOL(Z))/smoother,
                 shade=shade, ltheta=ltheta,
                 r=r,
                 theta=theta,
                 phi=phi,expand=expand, #mattc
                 
col=rep(rep(yred(NCOL(Z)/smoother),each=smoother),each=(NROW(Z)-1)),
                 scale=scale, border=border,box=box,...)

     x_axis <- seq(1, NROW(Z), 
length.out=length(time.axis))/length(time.axis)
     y_axis <- seq(1, NCOL(Z), length.out=NCOL(Z)/smoother)/smoother

     # x-axis
     xy0 <- trans3d(x_axis,y_axis[1],0,pm)
     xy1 <- trans3d(x_axis,y_axis[1]-0.3,0,pm)
     lines(trans3d(x_axis,y_axis[1],0,pm),col="#555555")
     segments(xy0$x,xy0$y,xy1$x,xy1$y, col="#555555")
     #text(xy1$x, xy1$y, 
labels=as.character(format(index(Z)[x_axis*10],"%m/%d/%y")), pos=1, 
offset=.25,cex=x.cex, srt=srt)
     text(xy1$x, xy1$y, labels=names(time.axis), pos=1, 
offset=.25,cex=x.cex, srt=srt)

     # y-axis
     xy0 <- trans3d(x_axis[length(x_axis)], y_axis, 0, pm)
     xy1 <- trans3d(x_axis[length(x_axis)]+.3, y_axis, 0, pm)
     yz0 <- trans3d(x_axis[length(x_axis)], y_axis, 
coredata(Z)[NROW(Z),seq(1,NCOL(Z),by=smoother)], pm) # vertical y
     lines(trans3d(x_axis[length(x_axis)], y_axis, 0, pm),col="#555555")
     segments(xy0$x,xy0$y,xy1$x,xy1$y,col="#555555")
     text(xy1$x, xy1$y, labels=cnames, pos=4, offset=.5,cex=x.cex)

    # segments(xy0$x,xy0$y,yz0$x,yz0$y, col="#555555") # y-axis vertical 
lines

     # z-axis
     z_axis <- seq(trunc(min(Z,na.rm=TRUE)), round(max(Z, na.rm=TRUE)))
     xy0 <- trans3d(x_axis[length(x_axis)], y_axis[length(y_axis)], 
z_axis, pm)
     xy1 <- trans3d(x_axis[length(x_axis)]+0.3, y_axis[length(y_axis)], 
z_axis, pm)
     lines(trans3d(x_axis[length(x_axis)], y_axis[length(y_axis)], 
z_axis, pm))
     segments(xy0$x,xy0$y,xy1$x,xy1$y)
     text(xy1$x, xy1$y, labels=paste(z_axis,'%',sep=''), pos=1, 
offset=-.5,cex=x.cex)

     title("Yield Curve") #mattc
     par(mar=c(5.1,4.1,4.1,3.1))
     return(invisible(pm))
   }

term.structure <- structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3.67, 3.4,
2.28, 2.15, 1.87, 1.68, 1.69, 1.76, 1.76, 1.77, 1.72, 1.69, 1.73,
1.7, 1.6, 1.48, 1.25, 1.2, 1.17, 1.21, 1.16, 1.13, 1.16, 0.81,
0.91, 0.98, 0.87, 0.96, 0.96, 0.9, 0.85, 0.95, 0.96, 0.83, 0.94,
1.17, 1.27, 1.45, 1.47, 1.73, 2.07, 1.89, 2.06, 2.51, 2.63, 2.7,
2.8, 2.99, 3.25, 3.41, 3.15, 3.77, 4, 4.01, 4.37, 4.47, 4.65,
4.6, 4.75, 4.54, 5.02, 5.12, 4.6, 5.18, 5.22, 4.75, 5, 5.24,
5.07, 4.8, 4.78, 4.28, 5.13, 4.02, 3.43, 4.01, 3.63, 2.76, 1.64,
2.07, 1.22, 1.17, 1.98, 1.6, 1.55, 1.63, 1.02, 0.12, 0.02, 0.11,
0.15, 0.16, 0.17, 0.04, 0.14, 0.17, 0.14, 0.11, 0.06, 0.01, 0.08,
0.04, 0.02, 0.09, 0.15, 0.14, 0.15, 0.17, 0.14, 0.16, 0.14, 0.14,
0.18, 0.07, 0.15, 0.13, 0.05, 0.02, 0.04, 0.01, 0.16, 0.01, 0.02,
0.02, 0.02, 0.01, 0.04, 0.08, 0.05, 0.07, 0.03, 0.04, 0.07, 0.09,
0.06, 0.09, 0.11, 0.02, 0.04, 0.07, 0.04, 0.03, 0.03, 0.02, 0.03,
0.02, 0.03, 0.03, 0.05, 0.01, 0.03, 0.04, 0.03, 0.02, 0.05, 0.02,
0.01, 0.02, 0.02, 0.01, 0.04, 0.03, 0.02, 8, 8.04, 8.07, 8.07,
8.01, 8, 7.74, 7.63, 7.37, 7.34, 7.24, 6.63, 6.37, 6.22, 5.92,
5.68, 5.71, 5.71, 5.7, 5.49, 5.26, 4.96, 4.47, 3.96, 3.94, 4.03,
4.15, 3.79, 3.79, 3.65, 3.25, 3.23, 2.75, 3.03, 3.38, 3.15, 2.96,
3.01, 2.95, 2.97, 3.13, 3.1, 3.1, 3.08, 2.98, 3.1, 3.21, 3.07,
3.05, 3.47, 3.56, 3.97, 4.31, 4.26, 4.39, 4.68, 4.8, 5.2, 5.72,
5.68, 6, 5.94, 5.88, 5.87, 5.81, 5.6, 5.6, 5.45, 5.4, 5.48, 5.48,
5.1, 5.05, 5.02, 5.13, 5.14, 5.18, 5.18, 5.32, 5.29, 5.14, 5.17,
5.13, 5.21, 5.15, 5.22, 5.35, 5.28, 4.96, 5.25, 5.25, 5.24, 5.06,
5.21, 5.22, 5.36, 5.19, 5.32, 5.16, 5, 5.03, 5.1, 5.1, 4.96,
4.37, 4.33, 4.57, 4.48, 4.48, 4.66, 4.49, 4.55, 4.66, 4.78, 4.75,
4.98, 4.88, 5.12, 5.3, 5.33, 5.76, 5.78, 5.88, 5.82, 5.63, 5.88,
6.27, 6.31, 6.23, 6.38, 6.21, 5.89, 4.99, 4.85, 4.3, 3.95, 3.63,
3.65, 3.54, 3.37, 2.4, 2.05, 1.78, 1.74, 1.76, 1.79, 1.79, 1.77,
1.74, 1.7, 1.71, 1.69, 1.57, 1.44, 1.22, 1.22, 1.18, 1.2, 1.14,
1.13, 1.11, 0.9, 0.96, 0.98, 0.95, 0.96, 0.93, 0.95, 0.92, 0.96,
0.95, 0.98, 1.08, 1.33, 1.45, 1.59, 1.71, 1.91, 2.23, 2.22, 2.51,
2.76, 2.79, 2.9, 2.99, 3.13, 3.42, 3.52, 3.55, 3.98, 3.95, 4.08,
4.47, 4.62, 4.63, 4.77, 4.86, 5.01, 5.1, 5.05, 4.89, 5.08, 5.03,
5.02, 5.12, 5.16, 5.04, 4.91, 4.73, 4.82, 4.96, 4.01, 3.82, 3.94,
3.15, 3.36, 1.96, 1.85, 1.38, 1.43, 1.89, 1.9, 1.68, 1.72, 0.92,
0.46, 0.01, 0.11, 0.24, 0.26, 0.21, 0.14, 0.14, 0.19, 0.18, 0.15,
0.14, 0.05, 0.06, 0.06, 0.08, 0.13, 0.16, 0.16, 0.16, 0.18, 0.15,
0.14, 0.16, 0.12, 0.17, 0.12, 0.15, 0.15, 0.09, 0.04, 0.06, 0.03,
0.1, 0.02, 0.02, 0.01, 0.01, 0.02, 0.06, 0.08, 0.07, 0.1, 0.07,
0.09, 0.11, 0.09, 0.1, 0.11, 0.08, 0.05, 0.07, 0.11, 0.07, 0.05,
0.04, 0.04, 0.04, 0.03, 0.02, 0.04, 0.06, 0.07, 0.02, 0.05, 0.05,
0.03, 0.04, 0.04, 0.03, 0.03, 0.02, 0.01, 0.02, 0.04, 0.02, 8.13,
8.14, 8.24, 8.44, 8.12, 8.02, 7.72, 7.74, 7.54, 7.46, 7.36, 6.73,
6.49, 6.32, 6.05, 5.83, 5.94, 5.95, 5.93, 5.6, 5.34, 5.03, 4.57,
4, 4.07, 4.14, 4.32, 3.97, 3.96, 3.77, 3.38, 3.35, 2.92, 3.29,
3.58, 3.38, 3.16, 3.14, 3.09, 3.07, 3.32, 3.22, 3.28, 3.21, 3.13,
3.28, 3.4, 3.3, 3.25, 3.72, 3.92, 4.45, 4.87, 4.83, 4.87, 5.03,
5.43, 5.72, 6.22, 6.51, 6.4, 6.19, 6.13, 6.08, 5.83, 5.59, 5.63,
5.53, 5.57, 5.55, 5.46, 5.17, 4.97, 5.05, 5.2, 5.3, 5.36, 5.37,
5.47, 5.49, 5.37, 5.3, 5.25, 5.33, 5.28, 5.39, 5.55, 5.53, 5.46,
5.34, 5.33, 5.39, 5.28, 5.32, 5.43, 5.45, 5.24, 5.33, 5.27, 5.24,
5.33, 5.24, 5.21, 5.03, 4.49, 4.36, 4.58, 4.55, 4.47, 4.7, 4.53,
4.66, 4.83, 5.04, 4.85, 5.21, 4.99, 5.28, 5.57, 5.74, 5.97, 6.02,
6.15, 6.12, 6.35, 6.23, 6.42, 6.38, 6.28, 6.36, 6.18, 5.7, 4.83,
4.7, 4.09, 3.97, 3.59, 3.63, 3.47, 3.31, 2.36, 1.95, 1.79, 1.83,
1.89, 1.87, 2.12, 1.91, 1.91, 1.75, 1.7, 1.67, 1.51, 1.43, 1.3,
1.23, 1.19, 1.19, 1.13, 1.15, 1.09, 0.98, 1.02, 1.06, 1.01, 1.04,
1.04, 1.02, 1.01, 1.01, 1.01, 1.17, 1.39, 1.68, 1.77, 1.79, 2,
2.13, 2.44, 2.59, 2.79, 3.01, 3.13, 3.17, 3.18, 3.34, 3.69, 3.74,
3.93, 4.26, 4.31, 4.37, 4.59, 4.74, 4.81, 4.91, 5.08, 5.24, 5.18,
5.11, 5.02, 5.13, 5.1, 5.09, 5.16, 5.12, 5.06, 5.03, 4.96, 4.93,
4.99, 4.21, 4.09, 4.09, 3.37, 3.49, 2.07, 1.83, 1.51, 1.64, 2.01,
2.17, 1.89, 1.97, 1.6, 0.94, 0.44, 0.27, 0.36, 0.45, 0.43, 0.29,
0.3, 0.35, 0.26, 0.24, 0.18, 0.16, 0.15, 0.2, 0.15, 0.19, 0.24,
0.25, 0.22, 0.22, 0.2, 0.19, 0.19, 0.17, 0.21, 0.19, 0.17, 0.18,
0.17, 0.11, 0.12, 0.1, 0.16, 0.05, 0.06, 0.06, 0.06, 0.06, 0.08,
0.13, 0.15, 0.15, 0.14, 0.16, 0.14, 0.14, 0.14, 0.16, 0.13, 0.11,
0.12, 0.13, 0.11, 0.09, 0.07, 0.1, 0.08, 0.05, 0.04, 0.08, 0.11,
0.1, 0.06, 0.08, 0.07, 0.05, 0.06, 0.07, 0.05, 0.05, 0.03, 0.05,
0.07, 0.12, 0.08, 8.08, 8.12, 8.35, 8.58, 8.22, 8.05, 7.72, 7.76,
7.69, 7.43, 7.31, 6.82, 6.51, 6.41, 6.28, 6.06, 6.16, 6.32, 6.19,
5.72, 5.42, 5.1, 4.69, 4.12, 4.23, 4.35, 4.54, 4.4, 4.24, 4.05,
3.62, 3.47, 3.06, 3.54, 3.83, 3.61, 3.39, 3.32, 3.32, 3.26, 3.62,
3.45, 3.53, 3.38, 3.39, 3.47, 3.65, 3.63, 3.53, 4.03, 4.5, 5.07,
5.38, 5.51, 5.37, 5.56, 5.96, 6.18, 6.91, 7.2, 6.84, 6.44, 6.49,
6.32, 5.8, 5.65, 5.67, 5.65, 5.65, 5.55, 5.36, 5.18, 4.9, 5.23,
5.41, 5.62, 5.77, 5.7, 5.85, 5.91, 5.71, 5.44, 5.38, 5.51, 5.58,
5.67, 6.02, 5.9, 5.78, 5.67, 5.45, 5.59, 5.47, 5.36, 5.52, 5.51,
5.24, 5.41, 5.41, 5.4, 5.42, 5.38, 5.38, 4.95, 4.41, 4.18, 4.53,
4.53, 4.51, 4.88, 4.72, 4.78, 4.97, 5.07, 5.13, 5.3, 5.22, 5.43,
5.7, 5.98, 6.3, 6.2, 6.28, 6.24, 6.37, 6.08, 6.07, 6.22, 6.07,
6.12, 5.92, 5.32, 4.6, 4.47, 4.09, 3.94, 3.63, 3.72, 3.53, 3.41,
2.49, 2.07, 2.06, 2.17, 2.29, 2.25, 2.7, 2.35, 2.34, 2.06, 1.8,
1.74, 1.53, 1.46, 1.56, 1.32, 1.31, 1.24, 1.19, 1.22, 1.13, 1.09,
1.28, 1.35, 1.15, 1.31, 1.39, 1.26, 1.28, 1.21, 1.2, 1.55, 1.83,
2.09, 2.13, 1.99, 2.21, 2.28, 2.63, 2.75, 2.96, 3.2, 3.35, 3.33,
3.32, 3.45, 3.8, 3.77, 4.01, 4.31, 4.34, 4.38, 4.58, 4.73, 4.82,
4.9, 5.07, 5.21, 5.11, 5.01, 4.91, 4.99, 4.94, 5, 5.09, 4.96,
4.9, 4.89, 4.95, 4.91, 4.85, 4.19, 4.05, 4.04, 3.26, 3.34, 2.11,
1.77, 1.55, 1.85, 2.22, 2.36, 2.27, 2.17, 1.78, 1.34, 0.9, 0.37,
0.51, 0.72, 0.57, 0.49, 0.47, 0.56, 0.48, 0.43, 0.4, 0.37, 0.27,
0.47, 0.3, 0.32, 0.41, 0.41, 0.34, 0.32, 0.29, 0.25, 0.27, 0.22,
0.27, 0.29, 0.26, 0.25, 0.3, 0.22, 0.18, 0.19, 0.2, 0.1, 0.13,
0.12, 0.12, 0.12, 0.13, 0.18, 0.19, 0.2, 0.18, 0.21, 0.16, 0.16,
0.17, 0.18, 0.18, 0.16, 0.15, 0.17, 0.14, 0.11, 0.14, 0.15, 0.11,
0.13, 0.1, 0.1, 0.13, 0.13, 0.1, 0.12, 0.13, 0.11, 0.1, 0.11,
0.12, 0.09, 0.13, 0.11, 0.13, 0.25, 0.17, 8.28, 8.43, 8.64, 8.96,
8.5, 8.24, 7.91, 8.07, 8.02, 7.77, 7.53, 7.15, 7.05, 7.04, 7.02,
6.8, 6.68, 6.9, 6.81, 6.36, 5.99, 5.7, 5.38, 4.77, 5.11, 5.27,
5.6, 5.46, 5.19, 4.83, 4.42, 4.15, 3.8, 4.4, 4.79, 4.56, 4.2,
3.92, 3.96, 3.83, 4.24, 4.03, 4.13, 3.88, 3.89, 3.99, 4.22, 4.25,
4.12, 4.67, 5.21, 5.73, 6.01, 6.19, 5.99, 6.17, 6.62, 6.84, 7.4,
7.69, 7.26, 6.79, 6.8, 6.6, 5.89, 5.79, 5.88, 5.85, 5.83, 5.61,
5.36, 5.18, 4.93, 5.44, 5.79, 6.03, 6.27, 6.11, 6.22, 6.34, 6.1,
5.77, 5.59, 5.88, 5.94, 6.09, 6.45, 6.29, 6.22, 6.08, 5.74, 5.97,
5.8, 5.63, 5.76, 5.66, 5.32, 5.55, 5.6, 5.59, 5.53, 5.49, 5.49,
4.91, 4.3, 4.12, 4.54, 4.54, 4.58, 5.13, 4.99, 5.08, 5.42, 5.53,
5.63, 5.73, 5.63, 5.79, 6.01, 6.24, 6.61, 6.53, 6.5, 6.68, 6.69,
6.38, 6.3, 6.18, 5.98, 5.94, 5.61, 5.11, 4.62, 4.41, 4.18, 4.3,
4.22, 4.25, 3.79, 3.64, 2.86, 2.44, 2.84, 3.07, 3.16, 3.06, 3.72,
3.24, 3.22, 2.9, 2.23, 2.14, 1.72, 1.68, 2.08, 1.61, 1.72, 1.53,
1.51, 1.51, 1.33, 1.32, 1.8, 1.95, 1.5, 1.85, 2.06, 1.84, 1.84,
1.66, 1.6, 2.31, 2.54, 2.7, 2.68, 2.41, 2.63, 2.56, 3.02, 3.08,
3.29, 3.59, 3.8, 3.66, 3.6, 3.66, 4.02, 3.84, 4.18, 4.4, 4.42,
4.41, 4.54, 4.69, 4.82, 4.87, 5.04, 5.16, 4.97, 4.79, 4.71, 4.71,
4.62, 4.82, 4.94, 4.65, 4.58, 4.6, 4.92, 4.87, 4.56, 4.15, 3.97,
3.94, 3.04, 3.05, 2.17, 1.65, 1.62, 2.29, 2.66, 2.63, 2.52, 2.36,
2, 1.56, 1, 0.76, 0.94, 1, 0.81, 0.91, 0.92, 1.11, 1.13, 0.97,
0.95, 0.9, 0.67, 1.14, 0.82, 0.81, 1.02, 0.97, 0.76, 0.61, 0.55,
0.47, 0.42, 0.34, 0.45, 0.61, 0.58, 0.69, 0.8, 0.61, 0.45, 0.45,
0.36, 0.2, 0.25, 0.25, 0.25, 0.25, 0.22, 0.3, 0.33, 0.27, 0.27,
0.33, 0.23, 0.22, 0.23, 0.3, 0.25, 0.25, 0.27, 0.25, 0.25, 0.22,
0.3, 0.36, 0.31, 0.39, 0.33, 0.31, 0.28, 0.38, 0.34, 0.33, 0.44,
0.42, 0.37, 0.47, 0.53, 0.48, 0.58, 0.5, 0.47, 0.67, 0.5, 8.36,
8.45, 8.69, 9.05, 8.53, 8.32, 8.04, 8.26, 8.19, 7.97, 7.67, 7.4,
7.3, 7.26, 7.3, 7.15, 7.1, 7.33, 7.21, 6.68, 6.28, 6.06, 5.76,
5.11, 5.65, 5.75, 6.17, 6.05, 5.75, 5.39, 4.97, 4.69, 4.34, 4.98,
5.36, 5.12, 4.72, 4.37, 4.42, 4.3, 4.63, 4.39, 4.5, 4.2, 4.24,
4.3, 4.55, 4.58, 4.44, 5.04, 5.66, 6.16, 6.36, 6.52, 6.33, 6.44,
6.92, 7.1, 7.62, 7.8, 7.39, 6.9, 6.92, 6.72, 5.95, 5.88, 6.02,
5.95, 5.91, 5.7, 5.41, 5.25, 5.06, 5.56, 5.91, 6.19, 6.44, 6.3,
6.39, 6.54, 6.28, 5.92, 5.7, 6.04, 6.08, 6.23, 6.6, 6.42, 6.37,
6.25, 5.81, 6.1, 5.88, 5.7, 5.8, 5.68, 5.35, 5.55, 5.61, 5.62,
5.54, 5.49, 5.48, 4.85, 4.26, 4.24, 4.54, 4.55, 4.57, 5.16, 5.07,
5.17, 5.51, 5.59, 5.7, 5.82, 5.7, 5.9, 6.05, 6.29, 6.65, 6.58,
6.44, 6.64, 6.66, 6.31, 6.24, 6.09, 5.91, 5.87, 5.52, 5.06, 4.67,
4.48, 4.33, 4.55, 4.49, 4.52, 4.06, 3.91, 3.22, 2.87, 3.3, 3.59,
3.7, 3.64, 4.31, 3.83, 3.73, 3.37, 2.67, 2.5, 2.02, 2.05, 2.51,
1.99, 2.16, 1.91, 1.93, 1.95, 1.58, 1.66, 2.33, 2.51, 1.95, 2.36,
2.56, 2.37, 2.35, 2.13, 1.99, 2.86, 3.1, 3.16, 3.09, 2.75, 2.89,
2.82, 3.29, 3.25, 3.43, 3.75, 3.96, 3.73, 3.65, 3.67, 4.06, 3.83,
4.18, 4.41, 4.41, 4.37, 4.49, 4.67, 4.83, 4.87, 5.03, 5.13, 4.93,
4.71, 4.62, 4.62, 4.52, 4.74, 4.85, 4.55, 4.54, 4.54, 4.88, 4.89,
4.55, 4.16, 4.03, 3.94, 3.09, 3.07, 2.27, 1.87, 1.79, 2.49, 2.93,
2.91, 2.81, 2.6, 2.28, 1.8, 1.27, 1, 1.32, 1.4, 1.15, 1.38, 1.42,
1.64, 1.62, 1.49, 1.45, 1.43, 1.12, 1.7, 1.38, 1.36, 1.6, 1.51,
1.26, 1, 0.84, 0.72, 0.64, 0.51, 0.72, 1.02, 0.98, 1.18, 1.29,
1.01, 0.79, 0.81, 0.55, 0.33, 0.42, 0.41, 0.41, 0.36, 0.3, 0.43,
0.51, 0.38, 0.35, 0.41, 0.3, 0.3, 0.31, 0.38, 0.34, 0.36, 0.42,
0.36, 0.36, 0.32, 0.52, 0.66, 0.61, 0.79, 0.63, 0.57, 0.56, 0.78,
0.69, 0.69, 0.9, 0.87, 0.79, 0.88, 1.02, 0.94, 1.07, 0.95, 0.88,
1.1, 0.81, 8.35, 8.44, 8.65, 9.04, 8.56, 8.35, 8.13, 8.5, 8.47,
8.24, 7.91, 7.68, 7.62, 7.66, 7.73, 7.63, 7.69, 7.9, 7.77, 7.34,
6.92, 6.74, 6.48, 5.93, 6.44, 6.58, 6.94, 6.91, 6.61, 6.29, 5.84,
5.6, 5.33, 5.9, 6.23, 6.04, 5.57, 5.21, 5.24, 5.14, 5.37, 5.05,
5.16, 4.8, 4.79, 4.83, 5.15, 5.21, 5.02, 5.6, 6.23, 6.64, 6.77,
6.97, 6.73, 6.81, 7.28, 7.48, 7.79, 7.83, 7.54, 7.06, 7.08, 6.88,
6.08, 5.98, 6.16, 6.07, 6.01, 5.81, 5.53, 5.38, 5.25, 5.73, 6.1,
6.4, 6.64, 6.47, 6.57, 6.73, 6.46, 6.1, 5.84, 6.21, 6.26, 6.39,
6.77, 6.57, 6.51, 6.4, 5.9, 6.22, 6, 5.72, 5.83, 5.71, 5.39,
5.59, 5.64, 5.65, 5.56, 5.47, 5.52, 4.91, 4.23, 4.24, 4.51, 4.56,
4.55, 5.21, 5.12, 5.24, 5.6, 5.67, 5.82, 5.88, 5.78, 5.97, 6.11,
6.36, 6.71, 6.61, 6.32, 6.56, 6.54, 6.18, 6.16, 5.98, 5.85, 5.83,
5.42, 4.99, 4.85, 4.7, 4.62, 4.97, 4.94, 4.97, 4.57, 4.46, 3.93,
3.66, 4.08, 4.38, 4.42, 4.27, 4.91, 4.53, 4.37, 4.09, 3.53, 3.22,
2.63, 2.81, 3.28, 2.78, 3.02, 2.69, 2.78, 2.85, 2.3, 2.46, 3.38,
3.46, 2.85, 3.27, 3.38, 3.25, 3.17, 3.01, 2.8, 3.63, 3.81, 3.81,
3.71, 3.33, 3.38, 3.3, 3.72, 3.63, 3.71, 4, 4.18, 3.9, 3.76,
3.72, 4.12, 3.87, 4.18, 4.45, 4.42, 4.35, 4.47, 4.61, 4.82, 4.92,
5.04, 5.1, 4.91, 4.7, 4.59, 4.57, 4.45, 4.7, 4.82, 4.52, 4.54,
4.51, 4.86, 4.92, 4.6, 4.25, 4.23, 4.16, 3.41, 3.45, 2.82, 2.5,
2.46, 3.03, 3.41, 3.34, 3.25, 3.1, 2.98, 2.8, 1.93, 1.55, 1.85,
1.99, 1.67, 2.02, 2.34, 2.54, 2.53, 2.39, 2.31, 2.31, 2.01, 2.69,
2.34, 2.3, 2.55, 2.43, 2.1, 1.79, 1.6, 1.33, 1.27, 1.17, 1.47,
2.01, 1.95, 2.13, 2.24, 1.97, 1.68, 1.76, 1.35, 0.96, 0.96, 0.99,
0.96, 0.83, 0.71, 0.87, 1.04, 0.82, 0.67, 0.72, 0.6, 0.59, 0.62,
0.72, 0.61, 0.72, 0.88, 0.77, 0.77, 0.68, 1.05, 1.41, 1.38, 1.62,
1.39, 1.31, 1.37, 1.75, 1.49, 1.51, 1.73, 1.69, 1.54, 1.62, 1.76,
1.63, 1.78, 1.62, 1.49, 1.65, 1.25, 8.39, 8.54, 8.7, 9.06, 8.64,
8.46, 8.28, 8.77, 8.73, 8.5, 8.18, 8, 7.89, 7.89, 7.96, 7.88,
7.92, 8.14, 8.03, 7.67, 7.29, 7.15, 6.99, 6.38, 6.92, 6.95, 7.25,
7.26, 7, 6.76, 6.27, 6.17, 5.94, 6.36, 6.61, 6.43, 6, 5.67, 5.72,
5.63, 5.8, 5.46, 5.5, 5.11, 5.11, 5.19, 5.53, 5.53, 5.34, 5.94,
6.59, 6.88, 6.99, 7.18, 6.92, 7, 7.46, 7.65, 7.84, 7.84, 7.58,
7.15, 7.17, 6.95, 6.18, 6.12, 6.35, 6.21, 6.11, 5.92, 5.68, 5.49,
5.46, 5.99, 6.3, 6.58, 6.78, 6.61, 6.68, 6.86, 6.6, 6.24, 5.97,
6.34, 6.4, 6.5, 6.89, 6.68, 6.61, 6.49, 5.99, 6.33, 6.11, 5.87,
5.89, 5.77, 5.51, 5.67, 5.74, 5.74, 5.63, 5.52, 5.56, 5.03, 4.38,
4.47, 4.7, 4.73, 4.72, 5.39, 5.38, 5.42, 5.83, 5.93, 6.1, 6.2,
6.1, 6.19, 6.28, 6.55, 6.75, 6.67, 6.28, 6.49, 6.52, 6.25, 6.19,
5.98, 5.93, 5.87, 5.5, 5.16, 5.08, 4.93, 4.86, 5.22, 5.27, 5.28,
4.86, 4.72, 4.37, 4.03, 4.55, 4.84, 4.82, 4.7, 5.29, 4.88, 4.77,
4.52, 4.09, 3.78, 3.25, 3.45, 3.88, 3.36, 3.55, 3.24, 3.35, 3.39,
2.87, 3.03, 3.98, 4, 3.41, 3.8, 3.89, 3.77, 3.68, 3.48, 3.33,
4.11, 4.26, 4.24, 4.13, 3.76, 3.79, 3.7, 4.07, 3.94, 3.92, 4.18,
4.33, 4.03, 3.86, 3.8, 4.19, 3.93, 4.23, 4.49, 4.45, 4.36, 4.49,
4.57, 4.83, 4.98, 5.06, 5.11, 4.93, 4.7, 4.6, 4.57, 4.45, 4.7,
4.82, 4.53, 4.58, 4.55, 4.87, 4.96, 4.67, 4.36, 4.38, 4.29, 3.64,
3.7, 3.19, 2.96, 2.88, 3.34, 3.68, 3.61, 3.56, 3.45, 3.38, 3.29,
2.35, 1.87, 2.27, 2.69, 2.28, 2.7, 3.06, 3.19, 3.14, 3.03, 2.93,
2.98, 2.69, 3.39, 3.08, 3.05, 3.28, 3.12, 2.75, 2.42, 2.3, 1.92,
1.91, 1.89, 2.16, 2.71, 2.71, 2.82, 2.9, 2.66, 2.37, 2.5, 2.09,
1.56, 1.43, 1.58, 1.53, 1.35, 1.24, 1.39, 1.61, 1.33, 1.03, 1.11,
0.98, 1.01, 1.04, 1.14, 1.04, 1.18, 1.38, 1.26, 1.24, 1.11, 1.55,
1.96, 2, 2.24, 2.02, 1.95, 2.1, 2.45, 2.13, 2.13, 2.3, 2.25,
2.06, 2.13, 2.24, 2.05, 2.22, 2.05, 1.89, 1.97, 1.53, 8.43, 8.51,
8.65, 9.04, 8.6, 8.43, 8.36, 8.86, 8.82, 8.65, 8.26, 8.08, 8.03,
8.02, 8.05, 8.02, 8.06, 8.24, 8.2, 7.82, 7.47, 7.47, 7.38, 6.71,
7.31, 7.27, 7.54, 7.61, 7.33, 7.14, 6.72, 6.62, 6.37, 6.8, 6.95,
6.7, 6.39, 6.03, 6.03, 6.05, 6.16, 5.8, 5.83, 5.45, 5.4, 5.43,
5.83, 5.83, 5.7, 6.15, 6.77, 7.06, 7.17, 7.34, 7.12, 7.19, 7.62,
7.81, 7.91, 7.84, 7.6, 7.22, 7.2, 7.07, 6.3, 6.21, 6.45, 6.28,
6.17, 6.03, 5.76, 5.58, 5.6, 6.13, 6.34, 6.66, 6.85, 6.73, 6.8,
6.96, 6.72, 6.37, 6.06, 6.43, 6.53, 6.56, 6.92, 6.72, 6.67, 6.51,
6.02, 6.34, 6.12, 5.84, 5.86, 5.75, 5.53, 5.62, 5.67, 5.68, 5.56,
5.44, 5.5, 5.05, 4.44, 4.64, 4.74, 4.65, 4.66, 5.29, 5.25, 5.36,
5.64, 5.81, 5.92, 5.98, 5.9, 6.02, 6.18, 6.45, 6.68, 6.42, 6.03,
6.23, 6.29, 6.03, 6.04, 5.73, 5.8, 5.77, 5.48, 5.12, 5.19, 4.92,
4.93, 5.35, 5.43, 5.42, 5.07, 4.85, 4.6, 4.3, 4.78, 5.07, 5.07,
4.88, 5.42, 5.11, 5.08, 4.86, 4.51, 4.14, 3.63, 3.93, 4.22, 3.83,
4, 3.71, 3.83, 3.89, 3.37, 3.54, 4.49, 4.45, 3.96, 4.33, 4.34,
4.27, 4.16, 3.99, 3.86, 4.53, 4.66, 4.62, 4.5, 4.13, 4.14, 4.05,
4.36, 4.24, 4.14, 4.36, 4.5, 4.21, 4, 3.94, 4.28, 4.02, 4.34,
4.57, 4.49, 4.39, 4.53, 4.55, 4.86, 5.07, 5.12, 5.15, 4.99, 4.74,
4.64, 4.61, 4.46, 4.71, 4.83, 4.56, 4.65, 4.63, 4.9, 5.03, 4.78,
4.54, 4.59, 4.48, 3.97, 4.04, 3.67, 3.53, 3.45, 3.77, 4.06, 3.99,
3.99, 3.83, 3.85, 4.01, 2.93, 2.25, 2.87, 3.02, 2.71, 3.16, 3.47,
3.53, 3.52, 3.4, 3.31, 3.41, 3.21, 3.85, 3.63, 3.61, 3.84, 3.69,
3.31, 2.97, 2.94, 2.47, 2.53, 2.63, 2.81, 3.3, 3.42, 3.42, 3.47,
3.32, 3.05, 3.18, 2.82, 2.23, 1.92, 2.17, 2.08, 1.89, 1.83, 1.98,
2.23, 1.95, 1.59, 1.67, 1.51, 1.57, 1.65, 1.72, 1.62, 1.78, 2.02,
1.89, 1.87, 1.7, 2.16, 2.52, 2.6, 2.78, 2.64, 2.57, 2.75, 3.04,
2.67, 2.66, 2.73, 2.67, 2.48, 2.53, 2.58, 2.35, 2.52, 2.35, 2.18,
2.17, 1.73, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
6.12, 6.46, 6.48, 6.29, 6.75, 7.23, 7.44, 7.58, 7.75, 7.46, 7.6,
7.98, 8.09, 8.1, 8.02, 7.81, 7.58, 7.54, 7.42, 6.72, 6.64, 6.88,
6.72, 6.6, 6.4, 6.2, 6.01, 6.07, 6.57, 6.83, 7.06, 7.17, 7.03,
7.07, 7.28, 7.05, 6.74, 6.45, 6.73, 6.86, 6.91, 7.22, 7.05, 6.99,
6.86, 6.35, 6.69, 6.47, 6.21, 6.12, 6.02, 5.88, 5.99, 6.02, 6.04,
5.9, 5.73, 5.81, 5.45, 5.17, 5.38, 5.33, 5.39, 5.35, 5.85, 5.92,
5.94, 6.15, 6.29, 6.4, 6.49, 6.47, 6.52, 6.62, 6.83, 6.72, 6.46,
6.2, 6.31, 6.42, 6.26, 6.13, 5.96, 6.13, 6.02, 5.78, 5.59, 5.65,
5.51, 5.6, 5.92, 5.95, 5.91, 5.61, 5.47, 5.45, 5.05, 5.54, 5.74,
5.68, 5.61, 6.03, 5.74, 5.77, 5.65, 5.41, 5.06, 4.75, 5.03, 5.18,
4.83, 4.93, 4.7, 4.84, 4.79, 4.36, 4.52, 5.43, 5.33, 4.91, 5.2,
5.2, 5.1, 5, 4.85, 4.77, 5.31, 5.39, 5.33, 5.24, 4.93, 4.89,
4.79, 5.03, 4.85, 4.64, 4.79, 4.88, 4.61, 4.4, 4.28, 4.56, 4.3,
4.62, 4.84, 4.81, 4.61, 4.74, 4.7, 5.07, 5.31, 5.35, 5.31, 5.17,
4.95, 4.84, 4.81, 4.66, 4.91, 5.02, 4.78, 4.92, 4.88, 5.1, 5.21,
5, 4.87, 4.89, 4.79, 4.44, 4.5, 4.35, 4.37, 4.3, 4.49, 4.74,
4.59, 4.63, 4.47, 4.43, 4.74, 3.71, 3.05, 3.86, 3.98, 3.61, 4.1,
4.34, 4.3, 4.29, 4.14, 4.02, 4.19, 4.07, 4.58, 4.38, 4.4, 4.55,
4.36, 4.05, 3.74, 3.74, 3.23, 3.38, 3.64, 3.8, 4.13, 4.33, 4.25,
4.29, 4.15, 3.91, 4.09, 3.77, 3.19, 2.66, 2.89, 2.77, 2.57, 2.59,
2.73, 3, 2.73, 2.27, 2.38, 2.21, 2.29, 2.42, 2.46, 2.37, 2.54,
2.79, 2.71, 2.71, 2.49, 2.95, 3.22, 3.34, 3.46, 3.41, 3.33, 3.54,
3.72, 3.35, 3.31, 3.31, 3.22, 3.05, 3.08, 3.07, 2.83, 2.98, 2.81,
2.62, 2.47, 2.05, 8.46, 8.54, 8.63, 9, 8.58, 8.41, 8.42, 8.99,
8.96, 8.78, 8.4, 8.26, 8.21, 8.19, 8.24, 8.2, 8.26, 8.42, 8.36,
8.06, 7.82, 7.91, 7.94, 7.41, 7.77, 7.8, 7.96, 8.06, 7.84, 7.79,
7.46, 7.42, 7.38, 7.63, 7.59, 7.4, 7.21, 6.9, 6.93, 6.95, 6.98,
6.68, 6.57, 6.09, 6.04, 5.96, 6.29, 6.35, 6.23, 6.67, 7.11, 7.31,
7.44, 7.63, 7.39, 7.46, 7.82, 7.97, 7.99, 7.89, 7.71, 7.46, 7.44,
7.34, 6.67, 6.63, 6.86, 6.65, 6.49, 6.34, 6.14, 5.96, 6.03, 6.48,
6.67, 6.89, 7, 6.9, 6.98, 7.13, 6.93, 6.66, 6.36, 6.65, 6.8,
6.8, 7.1, 6.95, 6.92, 6.8, 6.3, 6.61, 6.41, 6.15, 6.04, 5.93,
5.82, 5.92, 5.94, 5.95, 5.81, 5.62, 5.72, 5.3, 4.98, 5.15, 5.08,
5.09, 5.09, 5.57, 5.63, 5.68, 5.84, 5.98, 6.11, 6.07, 6.06, 6.16,
6.29, 6.48, 6.49, 6.15, 5.84, 5.97, 6.02, 5.9, 5.79, 5.67, 5.88,
5.79, 5.6, 5.46, 5.54, 5.34, 5.46, 5.78, 5.78, 5.75, 5.51, 5.39,
5.42, 4.89, 5.27, 5.48, 5.44, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 4.51, 4.9, 5.17, 5.21, 5.19,
5.07, 4.88, 4.77, 4.72, 4.56, 4.81, 4.93, 4.68, 4.84, 4.81, 5.01,
5.12, 4.92, 4.83, 4.83, 4.74, 4.4, 4.45, 4.35, 4.41, 4.3, 4.49,
4.72, 4.53, 4.59, 4.43, 4.31, 4.35, 3.45, 2.69, 3.58, 3.71, 3.56,
4.05, 4.34, 4.32, 4.31, 4.18, 4.03, 4.23, 4.2, 4.63, 4.51, 4.55,
4.72, 4.53, 4.22, 3.91, 3.98, 3.52, 3.69, 3.99, 4.12, 4.34, 4.58,
4.49, 4.51, 4.4, 4.22, 4.38, 4.12, 3.6, 2.9, 3.16, 3.06, 2.89,
2.94, 3.08, 3.35, 3.12, 2.67, 2.76, 2.56, 2.68, 2.82, 2.85, 2.81,
2.95, 3.17, 3.1, 3.1, 2.88, 3.3, 3.52, 3.64, 3.7, 3.69, 3.63,
3.82, 3.96, 3.61, 3.59, 3.56, 3.47, 3.33, 3.34, 3.32, 3.09, 3.21,
3.07, 2.89, 2.75, 2.29), class = c("xts", "zoo"), .indexCLASS = "Date", 
tclass = "Date", .indexTZ = "UTC", tzone = "UTC", index = 
structure(c(633744000,
636163200, 638755200, 641433600, 644112000, 646617600, 649382400,
652060800, 654480000, 657331200, 659923200, 662601600, 665280000,
667699200, 670118400, 672969600, 675648000, 678067200, 680918400,
683510400, 686188800, 688867200, 691372800, 694137600, 696816000,
699235200, 702000000, 704592000, 707097600, 709862400, 712540800,
715219200, 717811200, 720403200, 723081600, 725760000, 728265600,
730684800, 733536000, 736128000, 738547200, 741398400, 743990400,
746755200, 749347200, 751852800, 754617600, 757296000, 759974400,
762393600, 765072000, 767577600, 770342400, 772934400, 775440000,
778291200, 780883200, 783561600, 786153600, 788745600, 791510400,
793929600, 796608000, 799027200, 801878400, 804470400, 807148800,
809827200, 812332800, 815097600, 817689600, 820195200, 823046400,
825552000, 828057600, 830822400, 833500800, 835920000, 838771200,
841363200, 844041600, 846720000, 849225600, 851990400, 854668800,
857088000, 859766400, 862358400, 864950400, 867628800, 870307200,
872812800, 875577600, 878256000, 880675200, 883526400, 886118400,
888537600, 891302400, 893894400, 896400000, 899164800, 901843200,
904521600, 907113600, 909705600, 912384000, 915062400, 917568000,
919987200, 922838400, 925430400, 927849600, 930700800, 933292800,
936057600, 938649600, 941155200, 943920000, 946598400, 949276800,
951782400, 954460800, 956880000, 959731200, 962323200, 965001600,
967680000, 970185600, 972950400, 975542400, 978048000, 980899200,
983318400, 985910400, 988588800, 991267200, 993772800, 996537600,
999216000, 1001635200, 1004486400, 1007078400, 1009756800, 1012435200,
1014854400, 1017273600, 1020124800, 1022803200, 1025222400, 1028073600,
1030665600, 1033344000, 1036022400, 1038528000, 1041292800, 1043971200,
1046390400, 1049068800, 1051660800, 1054252800, 1056931200, 1059609600,
1062115200, 1064880000, 1067558400, 1069977600, 1072828800, 1075420800,
1077840000, 1080691200, 1083283200, 1085702400, 1088553600, 1091145600,
1093910400, 1096502400, 1099008000, 1101772800, 1104451200, 1107129600,
1109548800, 1112227200, 1114732800, 1117497600, 1120089600, 1122595200,
1125446400, 1128038400, 1130716800, 1133308800, 1135900800, 1138665600,
1141084800, 1143763200, 1146182400, 1149033600, 1151625600, 1154304000,
1156982400, 1159488000, 1162252800, 1164844800, 1167350400, 1170201600,
1172620800, 1175212800, 1177891200, 1180569600, 1183075200, 1185840000,
1188518400, 1190937600, 1193788800, 1196380800, 1199059200, 1201737600,
1204243200, 1206921600, 1209513600, 1212105600, 1214784000, 1217462400,
1219968000, 1222732800, 1225411200, 1227830400, 1230681600, 1233273600,
1235692800, 1238457600, 1241049600, 1243555200, 1246320000, 1248998400,
1251676800, 1254268800, 1256860800, 1259539200, 1262217600, 1264723200,
1267142400, 1269993600, 1272585600, 1275004800, 1277856000, 1280448000,
1283212800, 1285804800, 1288310400, 1291075200, 1293753600, 1296432000,
1298851200, 1301529600, 1304035200, 1306800000, 1309392000, 1311897600,
1314748800, 1317340800, 1320019200, 1322611200, 1325203200, 1327968000,
1330473600, 1333065600, 1335744000, 1338422400, 1340928000, 1343692800,
1346371200, 1348790400, 1351641600, 1354233600, 1356912000, 1359590400,
1362009600, 1364428800, 1367280000, 1369958400, 1372377600, 1375228800,
1377820800, 1380499200, 1383177600, 1385683200, 1388448000, 1391126400,
1393545600, 1396224000, 1398816000, 1401408000, 1404086400, 1406764800,
1409270400, 1412035200, 1414713600, 1417132800, 1419984000, 1422403200
), tzone = "UTC", tclass = "Date"), .Dim = c(301L, 11L), .Dimnames = 
list(
     NULL, c("1M", "3M", "6M", "1Y", "2Y", "3Y", "5Y", "7Y", "10Y",
     "20Y", "30Y")))

chartSeries3d0(term.structure,r=1,col=c("lightblue","darkblue"),
                
border=NA,theta=45,ltheta=0,shade=0.15,smoother=1,phi=15,scale=FALSE,expand=0.75)

Can anyone suggest a different package to work with to get closer to the 
above-mentioned output?  I'm interested in figuring out how to smooth 
the color transitions, add the grid/gridlines and use a different set of 
color gradients when the values are negative.  Also, I realize that my 
colors transition along the wrong axis (1m, 3m, etc) rather than along 
y.

Thanks in advance.  I've tried to find a reference to this in the 
archives and have come up empty.  As well, I've tried to make this 
reproducible.
Matt



More information about the R-help mailing list