Wednesday, June 19, 2013

R - Grammar of Graphics Figure 2.1


par(mar=c(1,1,1,1))
openplotmat()
elpos <- coordinates(3)
fromto <- matrix(ncol=2,byrow = T,data=c(1,2,2,3))
nr <- nrow(fromto)
arrpos <- matrix(ncol=2,nrow=nr)

for(i in 1:nr){
    arrpos[i,] <- straightarrow(to=elpos[fromto[i,2],],
                                from=elpos[fromto[i,1],],
                                lwd = 2, arr.pos = 0.68,
                                arr.length = 0.5)
}

textrect(elpos[1,],0.1,0.09,lab="Source",shadow.col = NULL)
textellipse(elpos[2,],0.1,0.09,lab="Make a pie",shadow.col = NULL)
textrect(elpos[3,],0.1,0.09,lab="Render",shadow.col = NULL)

text(arrpos[1,1]-0.07,arrpos[1,2]-0.08,"Data")
text(arrpos[2,1]-0.06,arrpos[2,2]-0.08,"Graphics")


No comments :

Post a Comment