1

我想在 ggplot 的 y 轴上在变量之间添加一个之字形(一个变量范围在 25 到 35 之间,另一个在 59 到 65 之间)。我尝试使用中断轴,但后来我需要使用绘图而不是 ggplot,我无法在绘图中获得相同的图表。有没有办法在 ggplot 中添加锯齿形?或者如何通过添加中断轴在绘图中获得相同的图表。

p11 <- ggplot(df18, aes(x=year, y=hba1c, shape = diabetes_class)) +
   geom_line(mapping= aes(x= df18$year, y = df18$hba1c, colour = "grey")) +
   geom_point(aes(x= rapportagejaar, y = hba1c, colour = "grey")) +
   geom_line(mapping = aes(x= year, y = df18$bmi, colour = "black")) + 
   geom_point(aes(x= year, y = bmi, colour = "black")) +
   labs(x='Year', y='Value', shape = "") +
   theme_classic() +
   scale_color_grey(name = "", labels = c("BMI","HbA1c")) +
   theme(text=element_text(size=10,  family="Arial"), legend.position = "top", axis.title.y.left = element_text(color = "black")) + 
   scale_y_continuous(limits = c(25,65), breaks = c(25,30,35,55,60,65))
4

0 回答 0