Sunday, January 11, 2015

How to plot “+” shape coordinate with R

First, we need initiate a new plot with plot function without x-y axis. If you want to define xlim and/or ylim, do this in this initiated plot with parameters xlim and ylim.


> plot (-2:4, c(-5, -4, 3, 4, 5, 2, 3), axes=FALSE, xlim=c(-6,6), ylim=c(-6, 6), xlab="", ylab="", main="")

Then, use axis to add the “+” shape coordinate.

> axis (1, pos=0, col="red", at=c(-6, -4, -2, 2, 4, 6))
> axis (2, pos=0, col="red", at=c(-6, -4, -2, 2, 4, 6))

“pos” show the x or y axis position, “at” show the ticks were marked at positions

For other properties, use ?axis to see.


No comments:

Post a Comment