我正在根据宿舍的房号(4位数)绘制住宿者的数量。房间号应该是字符串。但是当我使用as.character(RmNum)时,轴仍然显示为数字。
meanResidents = c(3, 4, 3, 2, 4, 5)
rmNumber = c(2034, 3043, 4012, 2035, 2022, 3013)
plot(as.character(rmNumber), meanResidents, xlab = as.character(rmNumber))我希望宿舍号码在中轴线上垂直显示。有人能帮我一下吗?
发布于 2013-06-28 00:19:20
使用函数axis,您可以指定轴的位置、放置刻度线(at)的位置并选择labels。参数las=2表示垂直于轴的标签。
plot(meanResidents, axes=FALSE, xlab="dorms")
axis(2)
axis(1, at=seq_along(meanResidents),labels=as.character(rmNumber), las=2)
box()

https://stackoverflow.com/questions/17347991
复制相似问题