Skip to content

Commit

Permalink
updated R code for plotting to add images onto plots
Browse files Browse the repository at this point in the history
  • Loading branch information
davdrose committed May 13, 2024
1 parent 3c3064d commit 604fbde
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions code/R/teleological_properties.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ output:
```{r, message=F}
library("xtable") # for saving tables
library("png") # for reading in png files
library("grid") # for arranging plots
library("emmeans") # for comparing models
library("knitr") # for knitting
library("RSQLite") # for reading in participants.db file
Expand Down Expand Up @@ -293,35 +295,53 @@ df.exp2.demographics %>%

```{r fig.height=4, fig.width=8, message=FALSE, warning=FALSE}
# Read the image file
midpoint_creature = readPNG("../../figures/plot_additions/midpoint_creature.png")
left_creature = readPNG("../../figures/plot_additions/midpoint_creature.png")
# Create a raster object from the image
raster_midpoint_creature = rasterGrob(midpoint_creature, interpolate=TRUE)
raster_left_creature = rasterGrob(left_creature, interpolate=TRUE)
ggplot(data = df.exp2.long,
mapping = aes(x = property,
y = response,
group = condition,
color = property,
fill = property,
shape = condition)) +
geom_hline(yintercept = 4, linetype = "dashed") +
geom_point(position = position_jitterdodge(dodge.width = 0.5,
jitter.width = 0.1,
jitter.height = 0.0),
alpha = 0.05) +
jitter.width = 0.15,
jitter.height = 0.1),
alpha = 0.2) +
theme(legend.position = "none") +
stat_summary(fun.data = "mean_cl_boot",
position = position_dodge(width = 0.5),
position = position_dodge(width = 0.55),
color = "black",
size = .5) +
size = .9) +
scale_fill_brewer(palette = "Set1") +
scale_color_brewer(palette = "Set1") +
scale_y_continuous(breaks = 1:7) +
scale_shape_manual(values = c(21, 23)) +
theme(plot.title = element_text(size=16, hjust = .5),
ggtitle("What is this creature?") +
xlab("Property type of creature \n\ that differed") +
theme(plot.title = element_text(size=24, hjust = .5),
legend.title = element_blank(),
legend.position = "bottom",
axis.title.x = element_blank()) +
axis.title.x = element_blank(),
axis.text.x = element_text(size=16),
axis.title.y = element_text(size=18),
axis.text.y = element_text(size=12),
legend.text = element_text(size=14)) +
guides(fill = "none",
color = "none",
shape = guide_legend(override.aes = list(fill = "gray50")))
ggsave(width = 5, height = 3, "../../figures/experiment2/exp2_property_by_condition_means.pdf")
shape = guide_legend(override.aes = list(fill = "gray50"))) +
coord_flip() +
annotation_custom(raster_midpoint_creature, xmin=4.35, xmax=5.3, ymin=-Inf, ymax=Inf) +
expand_limits(x = c(-Inf, 5.3))
# ggsave(width = 5, height = 3, "../../figures/experiment2/exp2_property_by_condition_means.pdf")
```

Expand Down
Binary file modified figures/experiment1/exp1_top_stacked.pdf
Binary file not shown.
Binary file modified figures/experiment2/bert_overall_property_means.pdf
Binary file not shown.
Binary file not shown.
Binary file modified figures/experiment2/exp2_heat_map.pdf
Binary file not shown.
Binary file modified figures/experiment2/exp2_property_by_condition_means.pdf
Binary file not shown.
Binary file modified figures/experiment3/exp3_heat_map.pdf
Binary file not shown.
Binary file modified figures/experiment3/exp3_property_by_condition_means.pdf
Binary file not shown.
Binary file modified figures/experiment4/exp4_heat_map.pdf
Binary file not shown.
Binary file modified figures/experiment4/exp4_property_by_condition_means.pdf
Binary file not shown.
Binary file added figures/plot_additions/midpoint_creature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 604fbde

Please sign in to comment.