axes labels for 3 variables

2019-09-08 17:32发布

问题:

My question is I want to plot a graph looking something like this

Where I want to make a simple plot of points with x and y labels. This part is fine, but then like in the photo I would like to add another label on another side matching the same data points of the other two axis So if I have a simple data set like

x   y   name 
1   1   A
2   3   B
3   3   C

How can I add the names A B and C on the top axis corresponding to the x,y points ?

thanks.

回答1:

If I understand right try

df=data.frame(x=c(1,2,3),y=c(1,3,3),name=c('A','B','C'))

plot(df$x,df$y)
axis(side = 3,labels = df$name,at=df$x)