I am plotting an interaction with this dataset:
X <- c(2.9, 4.0, 2.9, 4.0)
W <- c(2.5, 2.5, 4.3, 4.3)
Y <- c(1.8, 1.3, 1.5, 1.4)
df <- as.data.frame(cbind(X, W, Y))
df$wgroup <-
case_when(W == 2.5 ~ "Low W",
W == 4.3 ~ "High W")
df %>%
ggplot() +
aes(x = X, y = Y, group = wgroup) +
geom_line(aes(linetype = wgroup)) +
geom_point() +
scale_linetype_manual(values=c("dashed", "solid"))
I would like to adjust the x axis ticks and labels so that there are two labels "Low X" and "High X" with just one tick in between them.
I have tried both scale_x_continuous
and scale_x_discrete
, specifying labels and limits, but so far I haven't been able to get around the requirement that there be the same amount of labels and breaks.