I am trying to plot a three-way interaction in ggplot2 but it appears that the values in the generated plot, especially in the middle column, do not correspond to the values in my dataset, i.e., the raw data shows that nonwords were always slower than real words, but the middle column is showing the opposite pattern. I tried plotting another figure using similar code and data and incorrect values were again plotted.
Would appreciate it if anyone could tell me where the error in my code is.
g <- ggplot(m.df,
aes(x = ZMemScore,
y = exp(m.df$fit),
color = factor(Type))) +
geom_ribbon(aes(ymin=exp(m.df$lower), ymax=exp(m.df$upper), color = NA, fill = factor(Type)), linetype = 1, alpha=0.3) +
geom_line(aes(linetype = Type), size = 1.2) +
xlab("ZMemScore") + ylab("Predicted RT (ms)") + labs(color = "Type", subtitle ="ZQVT") +
facet_grid(. ~ ZQVT) +
scale_linetype_discrete(name='Type', labels=c('Nonword','Real Word')) +
theme_classic() + scale_color_manual(values=c("black", "firebrick2")) + theme(plot.subtitle = element_text(hjust = 0.5)) +
theme(text = element_text(size=14))+
guides(fill = FALSE, color = FALSE)
plot(g)
The generated plot: https://i.stack.imgur.com/IytLr.png
The values that were to plotted: https://i.stack.imgur.com/kPMRR.png
Thanks!