You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将geom_col柱状图上方的0值标签替换为n/a?

修改后的代码

geom_text(aes(label = ifelse(round(variable, digits = 0) == 0, "n/a", round(variable, digits = 0)), vjust = -0.5, colour = "black"))

说明

  • 用ifelse()函数做条件判断:先把variable四舍五入为整数,若结果是0就显示"n/a",否则保留四舍五入后的数值
  • 顺便删掉了你原代码里多余的逗号,避免语法报错

内容的提问来源于stack exchange,提问作者Kendra Bush

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 15:33:09