【问题标题】:names on the x-axis of barplot in R?R中barplot x轴上的名称?
【发布时间】:2015-02-09 18:43:55
【问题描述】:

我正在 r 中绘制条形图。

我的数据:

   ,Up,Down
Floor-1,690,1511
Maxim,1354,2515
Hosiptal,1358,2649
Bank,459,589
Air-port,1359,2097
Bus-stand,1234,1928
Taxi-Stand,213,138
Railway-station,557,610

脚本的条形图位于: Link to image

因为我没有足够的声望;我无法发布图像... :)

我的脚本是:

  d <- read.csv("file.csv")
  barplot(t(as.matrix(d[, 2:3])),beside=TRUE,legend = c("Up","Down"),  ylab = "Number of steps",
    xlab = "Building", main = "Up and Down steps",names.arg= as.matrix(d$X) ,col=rainbow(2),type="h")

在此图中,缺少 x 轴“巴士站”和“火车站”的标签。

如何标记那些缺失的标签?

【问题讨论】:

    标签: r bar-chart


    【解决方案1】:

    您可以尝试使用 cex.names 缩小标签

    x<- c(10, 20, 30, 40, 50)
    
    names <- c("Name", "Long name", "This name is long", "Name", "Name")
    
    barplot(x, names.arg=names)
    # Names might not all fit, depending on size of graph
    barplot(x, names.arg=names, cex.names=.5)
    # All names will probably fit
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-05
      • 2013-08-29
      • 1970-01-01
      • 2019-10-31
      • 2022-01-09
      • 1970-01-01
      • 2013-04-13
      • 1970-01-01
      相关资源
      最近更新 更多