Bạn có thể sử dụng đối số line
của axis()
đến nơi một trục cao hơn hoặc thấp hơn, theo cách này bạn có thể tạo ra nhiều trục. Với mtext()
, bạn có thể thêm nhãn vào một bên. Do lưu ý rằng cốt truyện riêng của mình chỉ là trên một quy mô, do đó bạn cần phải rescale điểm và nhãn của quy mô khác cho phù hợp:
# Plot and first axis:
plot(1:10,1:10,bty="n",col="red",pch=16,axes=FALSE,xlab="",ylab="")
axis(2,0:11,las=1)
axis(1,0:11,line=1,col="red",col.ticks="red",col.axis="red")
mtext("Label 1",1,line=1,at=0.2,col="red")
# Secondary points and axis:
points(rnorm(10,50,20)/10, rnorm(10,5,2),pch=16, col="blue")
axis(1,0:11,labels=0:11*10,line=3,col="blue",col.ticks="blue",col.axis="blue")
mtext("Label 2",1,line=3,at=0.2,col="blue")
Nguồn
2011-12-09 11:25:16