在R中的x轴上添加标签

在R中的x轴上添加标签,r,bar-chart,axis-labels,R,Bar Chart,Axis Labels,我想在条形图的x轴上添加一个标签。以下是我如何在R中生成条形图: x <- c(10,10,10,10,10) y <- c(45.57, 8, 8, 14,0.5 ) barplot(y, x) barplot(y, x, xaxt="n") 这是因为您没有读取barplot函数返回的内容(除了调用图形设备的副作用外)。它返回用户坐标中的位置,因此使用aat值: ?barplot # Read "Value" section barloc <- barplot(y, x

我想在条形图的x轴上添加一个标签。以下是我如何在R中生成条形图:

x <- c(10,10,10,10,10)
y <- c(45.57, 8, 8, 14,0.5 )
barplot(y, x)
barplot(y, x, xaxt="n")

这是因为您没有读取
barplot
函数返回的内容(除了调用图形设备的副作用外)。它返回用户坐标中的位置,因此使用a
at
值:

?barplot  # Read "Value" section
 barloc <- barplot(y, x, xaxt="n")
  axis(side = 1, 
   at=barloc, 
   lab=c(   "LT", 
            "LB", 
            "LBN", 
            "CD",
            "MLE"
         ),
   las=3)
?条形图#读取“值”部分

barloc请参见
条形图中的
名称.arg
参数。。。
?barplot  # Read "Value" section
 barloc <- barplot(y, x, xaxt="n")
  axis(side = 1, 
   at=barloc, 
   lab=c(   "LT", 
            "LB", 
            "LBN", 
            "CD",
            "MLE"
         ),
   las=3)