[R] Why points() is defined specially for a 1 by 2 matrix?
Peng Yu
pengyu.ut at gmail.com
Mon Oct 19 04:55:18 CEST 2009
x=cbind(1:4,3:6)
png('one_point.png')
plot(x[1:3,],xlim=c(-1,11),ylim=c(-1,11),pch=1)
points(x[4,],pch=2)# this is plotted as two points
#although I meant only one point
legend("topleft", c("x","y"),pch=c(1,2))
dev.off()
The above code will produce 5 points instead of 4 points. If I want to
have 4 points, I have to use the following code. But the below code is
a little bit tedious. I'm wondering if there is a way that I still use
the above code (with a little change) to generate 4 points?
x=cbind(1:4,3:6)
png('one_point_split.png')
plot(x[1:3,1],x[1:3,2],xlim=c(-1,11),ylim=c(-1,11),pch=1)
points(x[4,1],x[4,2],pch=2)
legend("topleft", c("x","y"),pch=c(1,2))
dev.off()
More information about the R-help
mailing list