Created
May 28, 2021 15:08
-
-
Save chrishaid/ac70a76f357eb0013d057865bde9027d to your computer and use it in GitHub Desktop.
Basic code for creating a satellite diagram (aka visual ANOVA)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# School and regional data (% of students earning 2+ on Mock AP exams) | |
schools_plot_df %>% | |
ggplot(aes(y=region, x = pct_2plus)) + | |
# plot the schools adn regions first | |
geom_point(aes(size = n_stus, | |
color = str_detect(school, "Average")), #Name of region = "Region Name Average" is in school field | |
show.legend = FALSE, | |
alpha = 0.75 #lighten up the points so we can see overlaps better | |
) + | |
# curve and text pointing out school average example | |
annotate("curve", x=.15, y=2.25, xend = .19, yend = 2.05, | |
color = idea_colors$magenta, | |
curvature = -.2, arrow = arrow(length = unit(2, "mm")))+ | |
annotate("text", x=.15, y=2.25, hjust = 1, | |
label = "One school", | |
color = idea_colors$magenta) + | |
# curve and text pointing out region average example | |
annotate("curve", x=.3, y=2.3, xend = .265, yend = 2.075, | |
color = idea_colors$darkblue, | |
curvature = .2, arrow = arrow(length = unit(2, "mm")))+ | |
annotate("text", x=.30, y=2.3, hjust = -0.01, | |
label = "Region's average", | |
color = idea_colors$darkblue) + | |
scale_color_idea(reverse = TRUE) + | |
scale_x_continuous(labels = scales::percent_format(), expand =expansion(mult = c(0, .1))) + | |
theme_idea_light() + | |
theme(axis.text.y = element_text(color = school_label_colors$color)) + | |
labs(y = "", | |
x = "% of AP Mock Exams earning 2+ points", | |
title = "Percent of Spring 20201 AP Mock Exams earning 2+ points", | |
caption = "Source: IDEA internal assessments") + | |
# + NULL is a trick to make it easy to comment out lines with out a + causing things to run over. | |
NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment