我希望下面的图表(其中有负值)使水平轴与0处的垂直轴交叉。我已经跟随其他说使用expand
命令的帖子,但这不起作用出于某种原因。
diff_votos <- structure(list(Grupo = c("Controle", "Tratado"),
N = c(32271L, 7623L),
diff_media = c(-0.3541 -0.4072),
diff_sd = c(2.0513, 1.6324),
Erro_padrao = c(0.0216, 0.0355)),
.Names = c("Grupo", "N",
"diff_media", "diff_sd", "Erro_padrao"),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -2L))
ggplot(diff_votos, aes(x = Grupo,
y = diff_media)) +
geom_bar(position = position_dodge(),
stat = 'identity',
colour = 'black',
width = 0.5) +
geom_errorbar(aes(ymin = diff_media - Erro_padrao,
ymax = diff_media + Erro_padrao),
position = position_dodge(width = 0.9),
width = 0.4,
size = 0.5) +
theme(legend.position = 'bottom',
axis.title = element_text(size = 10),
legend.text = element_text(size = 10),
axis.text = element_text(size = 10),
legend.title = element_text(size = 10)) +
labs(x = 'Grupo', y = element_blank()) +
scale_y_continuous(expand = c(0,0), limits = c(-0.6,0.6)) +
theme_classic()