如何使用 ggplot2 在 R 中正确创建此条形图?

问题描述 投票:0回答:0

示例数据如下:

library(tidyverse)
df=tibble(type=c('grass','forest','desert','crop'),
          temperature=c(0.6206,0.6132,0.6235,0.6134),
          precipitation=c(252,290,198,337),
          radiation=c(156,177,123,205))
dff <- df %>% pivot_longer(cols = -type,
                           names_to = 'n',
                           values_to = 'v')
dff
ggplot(data = dff)+
  geom_bar(aes(x=type,y=v,
               fill=n),
           stat = 'identity',
           position = 'dodge')

问题是“温度”变量太低而无法观察到它!!! 我怎样才能做出更好的身材? 提前致谢!

r ggplot2 bar-chart figure
© www.soinside.com 2019 - 2024. All rights reserved.