Skip to content
Prev 294158 / 398503 Next

additional axis, different scale

On May 10, 2012, at 8:07 AM, John Kane wrote:

            
There is:

a  <- c(10, 20, 30, 40)
b  <- c(50, 250, 500, 600)
ba <- b/a

par(las=1, mar=c(5,5,.5,5))
plot(a,b,     type="b", pch=22, cex=2, col=4, lwd=2, ylim=c(0,650),
xlim=c(0,45))
par(new=TRUE)
plot(a,ba,type="b", pch=21, cex=2, col=2, lwd=2, lty=1, xlim=c(0,45),  
yaxt="n")
  axis(4, at=c(seq(0,25,length=6)), lab=c(seq(0,25,length=6)),  
col.axis=2 )

# could also specify ylim of c(0,25) to the second plot call.

# probably want to have ylab="" in one or both of those plot calls, too.

But I do agree this can be considered deceptive plotting practice.