Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在ggplot中使用分组棒棒糖图制作错误条?_R_Ggplot2 - Fatal编程技术网

R 如何在ggplot中使用分组棒棒糖图制作错误条?

R 如何在ggplot中使用分组棒棒糖图制作错误条?,r,ggplot2,R,Ggplot2,我有一个分组棒棒糖图表的数据 grp percent percent_min perc_max Cold 82.3 81.5 83.5 Warm 84.4 82.2 86.3 这是我的图表的代码 dataframe %>% ggplot(aes(grp, percent)) + geom_linerange(aes(x = grp, ymin =

我有一个分组棒棒糖图表的数据

grp     percent   percent_min   perc_max
Cold       82.3          81.5   83.5
Warm       84.4          82.2   86.3
这是我的图表的代码

  dataframe %>%
  ggplot(aes(grp, percent)) + 
  geom_linerange(aes(x = grp, 
                     ymin = 75, 
                     ymax = percent), 
                 position = position_dodge(width = 1)) +
  geom_point(size = 7, 
             position = position_dodge(width = 1)) 
我尝试使用
geom\u errorbar
为这两个行范围添加错误条

我不知道如何让它与他们一起工作


如何获得“冷”的一个错误栏和“热”的另一个错误栏?

您可以使用以下代码

library(tidyverse)

dataframe %>%
  ggplot(aes(grp, percent)) + 
  geom_linerange(aes(x = grp, 
                     ymin = 75, 
                     ymax = percent), 
                 position = position_dodge(width = 1)) +
  geom_point(size = 7, position = position_dodge(width = 1)) +
  geom_errorbar(aes(ymin = percent_min, ymax = perc_max))

资料
您可以使用以下代码

library(tidyverse)

dataframe %>%
  ggplot(aes(grp, percent)) + 
  geom_linerange(aes(x = grp, 
                     ymin = 75, 
                     ymax = percent), 
                 position = position_dodge(width = 1)) +
  geom_point(size = 7, position = position_dodge(width = 1)) +
  geom_errorbar(aes(ymin = percent_min, ymax = perc_max))

资料