I want geom_line to connect 0 to 0-2 then 2-5 and 5-10, in the following order and not based on the X-axis data. Except for one point, others are correct. Here is my script.
ggplot(dat_combined, 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_line(aes(group = interaction( Type, site)))+
geom_point(aes(color = site, shape = Type),size = 3,
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()
Here is the output.
One of the lines goes from depth 0 to 5-10, not following the order of depth.