library(data.table) library(ggplot2) library(patchwork) library(colorspace)
data_comp = fread("data/results/data_sc3_comp_choice.csv") # data_comp = data_comp[gen == 950,] data_comp = data_comp[, list( prop_steal = sum(steal) / (2500) ), by = c("food", "handlers", "gen", "rep")] fig_comp = ggplot(data_comp)+ geom_tile( aes( food, handlers, fill = prop_steal ) )+ scale_fill_continuous_sequential( palette = "Purple-Yellow", limits = c(0, 1), breaks = c(0, 0.5, 1), labels = scales::percent_format(accuracy = 1), na.value = "white" )+ scale_x_continuous( breaks = seq(0, 5) )+ scale_y_continuous( breaks = seq(0, 5) )+ facet_grid( cols = vars(gen), rows = vars(rep), # ncol = 3, labeller = labeller( gen = function(x) sprintf("Gen = %s", x), rep = function(x) sprintf("Rep: %s", x) ) )+ coord_cartesian( expand = F )+ theme_test( base_size = 10, base_family = "Arial" )+ theme( legend.position = "top", legend.key.height = unit(1, "mm"), legend.key.width = unit(4, "mm"), legend.title = element_text( vjust = 1.2 ), strip.text = element_text( face = "italic" ), strip.background = element_blank(), )+ labs( x = "# Prey-items", y = "# Handlers", fill = "% Consumers\nstealing" ) ggsave( fig_comp, filename = "supplement/figures/fig_sc3_comp_evol.png", height = 4, width = 6 )
\newpage
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.