axes labels for 3 variables

房东的猫 提交于 2019-12-11 18:36:53

问题


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)


来源:https://stackoverflow.com/questions/33940163/axes-labels-for-3-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!