【问题标题】:is there a way to rename the range name in y-axis in chart?有没有办法重命名图表中 y 轴的范围名称?
【发布时间】:2022-11-02 22:47:42
【问题描述】:
rank <- as.numeric(rank)
rank[is.na(rank)] <- 0

scale_y_reverse(休息 = 0:28)


这就是我现在得到的结果,但我希望它变成“新的” 0 1 2 3 ... 如图所示:

它有一些“新”的排名。因此我将其更改为数字格式,然后“新”变为 NA。但是我想展示它然后我将它设为 NA 为 0。但现在我希望情节中的 0 成为一个“新”词。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    您可以将labels 参数用于replace() 第一个值:

    library(ggplot2)
    
    ggplot() + 
      aes(y = 0:10) +
      scale_y_reverse(breaks = 0:10, labels = ~ replace(.x, 1, "New")) 
    

    【讨论】:

      猜你喜欢
      • 2011-03-26
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多