How to center ggplot label on multiple geom_pointranges?

Solution 1:

You can pass the position parameter in the geom_label call. Just set it to position_dodge(width= 0.4).

The code looks like this:

ggplot(DF, aes(x = Group , y = AME, color = PID_3 , ymin = lower, ymax = upper, label = round(AME,2))) +
  facet_wrap(Model  ~ ., scale = "free_x" ) +
  geom_pointrange(position = position_dodge(width= 0.4)) +
  coord_flip() +
  geom_label(position = position_dodge(width = 0.9)) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "grey") +
  guides(color="none") +
  theme_bw() +
  labs(title = "Average Marginal Effects of Affective Polarization on the Likelihood of Biden Vote",
       subtitle = "Across Party Identification and Alternative Measures of Affective Polarization",
       y = "Average Marginal Effects",
       caption= "Note: Point estimates are dots with lines indicating 95 percent confidence intervals.\nModel: Logistic Regression.\nAverage marginal effects calculated using sd") +
  theme(plot.title = element_text(hjust = 0.5),
        plot.subtitle = element_text(hjust = 0.5),
        plot.caption= element_text(hjust = 0),
        axis.title.y=element_blank())

And the output: enter image description here