0

The data point and error bars are far away in the generated figure.

Here is the script

dat_combined %>%
  arrange(depth_cm) %>%
  ggplot(aes(x = mean_delta_13C, y = depth_cm)) +
  geom_errorbarh(aes(xmin = mean_delta_13C - sd_delta_13c, 
                     xmax = mean_delta_13C + sd_delta_13c, color = site),
                 height = 0.2, size = 0.5,  
                 position = position_dodge2(width = 0.3))   +
  geom_path(aes(group = interaction( Type, site)))+
  geom_point(aes(color = site, shape = Type),size = 2.5, 
             position = position_dodge2(width = 0.1)) +
  scale_color_manual(values = site_colors, labels = new_names) +
  labs(x = expression(delta^13*"C (‰)"), y = "Soil depth (cm)", color = "Ecosystem", shape = element_blank())+
  scale_x_reverse(position = "top") +
  scale_y_discrete(limits = rev(depths)) +  
  theme_pubr() 

Generated Figure (problem highlighted in green encircle)

enter image description here

J.M
  • 25
  • 4
  • 1
    Please provide a minimal reproducible example, this will make helping you much easier: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Julian May 03 '23 at 14:38
  • 1
    Your `position_dodge2(width = 0.3)` in `geom_errorbarh` and `position_dodge2(width = 0.1)` in `geom_point` essentially means that the distance between your top and bottom error bars at each `depth_cm` point will be three times the distance between the corresponding points. – Andy Baxter May 03 '23 at 18:25
  • I have updated my data. Can you have a look? Thanks @Julian – J.M May 05 '23 at 12:52

0 Answers0