1

I want to add a zigzag on the y-axis in ggplot in between to variables (one variable ranges between 25 and 35 and the other between 59 and 65). I tried to use break axis, but then I need to use plot instead of ggplot and I am not able to get the same graph in plot. Are there ways to add a zigzag in ggplot? Or how do I get the same graph in plot with the adding of break axis.

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))
Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
  • 1
    There is no way in vanilla ggplot2 to make interrupted axes. This is for good reasons too, as it distorts the interpretation of the data. I'd say your best bet would be to facet on the variables, log-transform the values or figure out how to make the same graph in base R. – teunbrand Aug 26 '20 at 09:32

0 Answers0