How to Print Characters on a Plot in R
Code
You can use the text()
function to place text on the graph.
The first option is a vector of $x$ axis coordinates, the second option is a vector of $y$ axis coordinates, and the third option is a vector of strings to input.
You will understand immediately if you try running the example code below with only changing t
.
win.graph(6,5)
plot(x=0,y=0,xlim=c(-1,5),ylim=c(-1,4),xlab="x",ylab="y")
points(4,3,col="red",pch=19)
#1
abline(h=0)
#2
abline(v=0)
#3
abline(0,3/4)
#4
segments(4,0,4,3)
x=c(2,-0.2,2,4.2)
y=c(-0.2,2,2,2)
t=c("(1)","(2)","(3)","(4)")
t=c("(하나)","(둘)","(삼)","(넷)")
t=c("One","Two","Three","Four")
text(x,y,t)