例:
d <- data.frame(name=c("zhao","qian","sun","li"),weight=c(62,58,79,60),height=c(178,169,180,173)) x <- d$name y1 <- d$weight y2 <- d$height
用包plotrix
#png("2y_1.png") library(plotrix) xpos <- 1:4 twoord.plot(xpos,y1,xpos,y2,xlim=c(0,5),lylim=c(0,100),rylim=c(100,190), lcol=4,rcol=2,xlab="name",ylab="Weight (kg)",rylab="Height (cm)",type=c("bar","b"),xticklab=x,halfwidth=0.2) #dev.off()
注:lylim=c(0,100),rylim=c(100,190)表示左y轴,右y轴取值范围