geom_bar返回1

标记

我正在尝试从数据框中绘制条形图。条形图的高度全部返回为1。下面是可复制代码的示例:

df <- data.frame(country = c("China", "USA", "South Korea"),
                 confirmed = c(4747763, 90, 2060))
ggplot(df, aes(x = country, fill = country)) +
  geom_bar()

为什么钢筋高度与我的数据框中“已确认”列中的数值不匹配?

标记

得到它了。必须设置stat =“ identity”才能使geom_bar读取y轴:

    df %>%
       ggplot(aes(x = country, y = confirmed)) +
       geom_bar(stat = "identity")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章