Position problem with geom_bar when using both width and dodge
问题 I have the following data frame group1 = c('a', 'b') group2 = c('1', '1', '2', '2') mean = 1:4 sd = c(0.2, 0.3, 0.5, 0.8) df = data.frame(group1, group2, mean, sd) I want to plot the sd on the graph, either with geom_errorbar() . This works perfectly: ggplot(data = df, aes(x=group1, y = mean))+ geom_col(position = 'dodge') + geom_errorbar(aes(ymin = mean - sd, ymax = mean + sd), position = 'dodge') As I wanted to reduce the width of the error bars I run: ggplot(data = df, aes(x=group1, y =