Skip to content

Instantly share code, notes, and snippets.

@saralilyb
Last active January 20, 2018 17:54
Show Gist options
  • Save saralilyb/47424cf6637f969e635e079ef8d95d2a to your computer and use it in GitHub Desktop.
Save saralilyb/47424cf6637f969e635e079ef8d95d2a to your computer and use it in GitHub Desktop.
is <- 12/2 # in units on the drawn grid, NOT pixels
relvals <- c(9, 25, 41, 59, 75, 91)
incvals <- c(9, 25, 41, 59, 75, 91)
imagelist <- list()
# loop through and make list of grobs using both
for (r in relvals) {
for (i in incvals) {
strvals <- paste("/Users/jtth/diss/RFCs/", r, "-", i, ".png", sep = "")
grob <- rasterGrob(readPNG(strvals), interpolate = FALSE)
v <- list(img = grob, x = r, y = i)
imagelist <- c(imagelist, list(v))
}}
# set the plot up
p <- ggplot(data = NULL, aes(y = 1:100, x = 1:100)) +
xlab("relevant") +
ylab("incidental") +
labs(title = "Experiment 1 typicality rating stimuli") +
annotate("text", x = 69, y = 50, label = "Incidental trough", angle = 0, family = myfont, color = "black") +
annotate("text", x = 50, y = 70, label = "Category boundary", angle = 90, family = myfont, color = "black") +
scale_x_continuous(limits = c(0, 100), breaks = relvals) +
scale_y_continuous(limits = c(0, 100), breaks = incvals) +
#geom_rangeframe() +
theme_tufte(myfontsize, ticks = F, base_family = myfont) +
theme(axis.title.x = element_text(size = myfontsize, vjust = -0.5), axis.title.y = element_text(size = myfontsize, vjust = 1), legend.justification=c(1,0), legend.position=c(.95, .1))
# add in stimuli by appending annotations to the plot
for (g in imagelist) {
p <- p + annotation_custom(g$img, xmin = g$x - is, xmax = g$x + is, ymin = g$y - is, ymax = g$y + is)
}
p
@saralilyb
Copy link
Author

Generates this graph.
screen shot 2018-01-20 at 12 49 45 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment