【发布时间】:2013-06-27 16:03:37
【问题描述】:
我正在根据宿舍房间号(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))
我希望宿舍号码在轴上垂直显示。有人可以帮我吗?
【问题讨论】:
-
请给我们你的代码和一个小数据集,我们可以用它来重现问题。
-
@Roland meanResidents = c(3, 4, 3, 2, 4, 5); rmNumber = c(2034, 3043, 4012, 2035, 2022, 3013)。
-
@Roland 我的代码是 plot(as.character(rmNumber), meanResidents, xlab = as.character(rmNumber)) 但 xaxis 显示的是数字而不是字符串。
-
我也试过 plot(as.character(rmNumber), meanResidents, xlab ='n', xaxt = 'n'); axis(1, at=seq(1, length(rmNumber), 1), labels=as.character(rmNumber), las =2) 还是不行....
标签: r plot axis-labels vertical-text