I have a boxplot showing scores 'before' and 'after' an intervention. I want to a few dots a different color, based on another score.
In other words, say ten subjects had scores of (8,9,10,8,9,10,8,9,10,8) before an intervention, and (12,9,12,8,9,10,10,9,10,10) after an intervention. Right now, using standard ggplot boxplot, I am showing group 1 and group 2 as boxplots with different colors. I would like to color a few subjets with a third colour (seen in the before and after plots), demonstrating the presence of an additional binary variable (like age > 50).
PreopRespondersBoxPlotLDS <- ggboxplot(data=PreopResponders,
x="Response",y="RespondersVsNonPreopLDS.preop", color = "Response", palette =
"jco", add = "jitter") + labs(title = "Left Dorsal Striatum Connectivity to the Right Occipital Cortex", y = "Connectivity")
+ theme(axis.title.x = element_blank(), legend.position="none", legend.title = element_blank(), plot.title = element_text(hjust = 0.5))
I'm not getting an error message, I just want to be able to use an extra color to code for a binary variable.
+ geom_point()
to your graph. Give it the subset of data you want points for,geom_point(data = subset(PreopResponders, ::criteria::))
. If you want to add colors for those points, add a mapping for that layer,geom_point(data = subset(PreopResponders, ::criteria::), aes(color = binary_variable_name))
. If you need more help, please post a sample of your data.dput()
is the nicest way to share data because it is copy/pasteable. – Gregor Thomas