axes labels for 3 variables

2019-09-08 17:29发布

My question is I want to plot a graph looking something like this enter image description here

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条回答
姐就是有狂的资本
2楼-- · 2019-09-08 17:59

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)
查看更多
登录 后发表回答