我想绘制 10 个不同分子的强度值的直线图,x 轴为分子名称,y 轴为强度值。
我试过:
x = c("Mol 1","Mol 2","Mol 3","Mol 4","Mol 5","Mol 6","Mol 7","Mol 8","Mol 9","Mol 10")
intensity = c(428,409,388,378,373,140,137,138,139,144)
plot(x,intensity)
但它返回了这个错误信息?
plot.window(...) 中的错误:需要有限的“xlim”值
此外: 警告消息:
1: 在 xy.coords(x, y, xlabel, ylabel, log) : 由强制引入的 NAs
2:在 min(x) 中:没有非缺失的 min 参数;返回信息
3:在 max(x) 中:没有非缺失的 max 参数;返回 -Inf
最佳答案
因为您的 x 变量是离散的,所以您需要以不同的方式执行此操作:
plot(seq_along(x),intensity,type = "l",axes = FALSE)
axis(side = 2)
axis(side = 1,at = seq_along(x),labels = x)
这个想法是您创建带有 x 轴数值的图,然后简单地添加您的特定标签。
您可以添加到
box()
的电话如果您错过了情节周围的完整框。
关于r - 在 x 轴上绘制带有标签的图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20332131/