This is driving me nuts. What I want to do is to overlay the two attached plots (referred to as the “dots plot" and the “jags plot"for visually apparent reasons). Discovery learning is not working, neither are endless variations on web searches.
Here are the basics: I have a large number of dependent variables that fall on the same x-axis. The x-axis runs from 1-248 in intervals of 1 (call this “games”). Both plots show different aspects of the same 10 variables. The “dots" plot is categorical and the “jags” plot is continuous.
The continuous variables rises and falls across the 248 games, but mostly rises as expertise increases. There is one “measure” for each variable for each game.
The second categorical variable, “changepoints”, indicates games at which the game-to-game rise (or fall) for these two variables differed than what would have been expected. Our “changepoint” measure yields 1-7 changepoints for each of the 10 variables shown in the dot plot. (There are, of course, more players and more variables — but those issues are easy to handle.)
For ease of inspection, I would to overlay the dots with the jags for each of the measures.
This seems like a simple problem to solve but I am bewildered by it. My failed code won’t help anyone. However, I have included the much simpler code for each plot. — but I think the plots are more useful.
Thanks!
Wayne
############################
Dot plot code:
for(sid in unique(scd.ss$SID)){
plotCPTs <- subset(scd.ss, SID == sid)
plotprint = ggplot(plotCPTs, aes(x = ChangePoint, y=score_type, color = score_type)) +
ggtitle(sid) + theme(plot.title = element_text(lineheight=1, face="bold")) +
geom_line() + geom_point(aes(size=12)) + theme(legend.position="none") +
scale_y_discrete(name="Measures and Factors") +
scale_x_continuous(name="Games", limits=c(1,248), breaks= seq(from = 0, to = 248, by = 31)) +
theme(axis.title.x = element_text(face="bold", colour="#990000", size=20)) +
theme(axis.title.y = element_text(face="bold", colour="#990000", size=20)) +
theme(axis.text.y = element_text(angle = 60, size=12)) +
## vertical lines are "visual aids" only
geom_rect(aes(xmin=24, xmax=24, ymin=-Inf, ymax=Inf), fill="gray90", alpha=0.1, linetype="solid") +
geom_rect(aes(xmin=74, xmax=74, ymin=-Inf, ymax=Inf), fill="gray90", alpha=0.1, linetype="solid") +
geom_rect(aes(xmin=124, xmax=124, ymin=-Inf, ymax=Inf), fill="gray90", alpha=0.1, linetype="solid") +
geom_rect(aes(xmin=174, xmax=174, ymin=-Inf, ymax=Inf), fill="gray90", alpha=0.1, linetype="solid") +
geom_rect(aes(xmin=224, xmax=224, ymin=-Inf, ymax=Inf), fill="gray90", alpha=0.1, linetype="solid")
ggsave(paste0("plots_160105/DotPointPlots/", sid, ".pdf"), width=8.5, height=14, plotprint)
}
Jaggy plot code:
for(sid in unique(
run.me$SID)){
plotSCORE <- subset(
run.me, SID == sid)
plotprint = ggplot(plotSCORE, aes(x=Game, y = score_value, group = score_type)) +
theme_bw() +
geom_line(color="darkgreen") +
geom_point(color="black") +
facet_grid(score_type ~. , scales="free_y") + theme_bw() +
ggtitle("Changepoints determined by running cpt.meanvar on Total score")
ggsave(paste0(
plot.me, sid, ".pdf"), width=14, height=14, plotprint)
}