Web EndMemo

R Draw Points

points(...) function adds a group of points to plot. It's usage is:

points(x, y, ...)

x,y:Vector of coordinates

First let's make a scatter plot:
>x <- c(1.2,3.4,1.3,-2.1,5.6,2.3,3.2,2.4,2.1,1.8,1.7,2.2)
>y <- c(2.4,5.7,2.0,-3,13,5,6.2,4.8,4.2,3.5,3.7,5.2)

Add some points to the plot:
>x2 <- c(4.1,1.1,-2.3,-0.2,-1.2,2.3)
>y2 <- c(2.3,4.2,1.2,2.1,-2,4.3)

Notice that there is a point almost out of the left border. If the added points are out of the plot border, they were not be added to the plot. In the example above, the smallest value of x is -2.1, and largest is 5.6, the y value range is -3 < y < 13, so the added points should be inside that range.

The cex= controls the size of the points, pch= controls the point shape, and col= controls the point color. Here is a list of all pch symbols, and here is a complete chart of R color names. Let add some points of filled diamond shape, large size, and red color:
>x3 <- c(0,4)
>y3 <- c(10,-0.5)