1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
get.tablepos<-function(x) {
plotlim<-par("usr")
tablepos<-list()
if(x == "bottomleft") {
tablepos$x<-plotlim[1]
tablepos$y<-plotlim[3]
tablepos$xjust<-0
tablepos$yjust<-1
}
if(x == "bottom") {
tablepos$x<-(plotlim[2]+plotlim[1])/2
tablepos$y<-plotlim[3]
tablepos$xjust<-0.5
tablepos$yjust<-1
}
if(x == "bottomright") {
tablepos$x<-plotlim[2]
tablepos$y<-plotlim[3]
tablepos$xjust<-1
tablepos$yjust<-1
}
if(x == "left") {
tablepos$x<-plotlim[1]
tablepos$y<-(plotlim[3]+plotlim[4])/2
tablepos$xjust<-0
tablepos$yjust<-0.5
}
if(x == "right") {
tablepos$x<-plotlim[2]
tablepos$y<-(plotlim[3]+plotlim[4])/2
tablepos$xjust<-1
tablepos$yjust<-0.5
}
if(x == "topleft") {
tablepos$x<-plotlim[1]
tablepos$y<-plotlim[4]
tablepos$xjust<-0
tablepos$yjust<-0
}
if(x == "top") {
tablepos$x<-(plotlim[2]+plotlim[1])/2
tablepos$y<-plotlim[4]
tablepos$xjust<-0.5
tablepos$yjust<-0
}
if(x == "topright") {
tablepos$x<-plotlim[2]
tablepos$y<-plotlim[4]
tablepos$xjust<-1
tablepos$yjust<-0
}
# if no recognizable position was passed, put it in the center
if(x == "center" || length(tablepos)==0) {
tablepos$x<-(plotlim[1]+plotlim[2])/2
tablepos$y<-(plotlim[3]+plotlim[4])/2
tablepos$xjust<-0.5
tablepos$yjust<-0.5
}
return(tablepos)
}
|