library(data.table) library(ggplot2) library(patchwork) library(colorspace)
# load relative preferences data_pref = fread("data/results/data_rel_pref.csv") data_pref = data_pref[gen == 950,] # no foragers data_pref = data_pref[sim_type %in% c("obligate", "facultative")] data_pref$sim_type = factor(data_pref$sim_type, levels = c("obligate", "facultative"))
fig_variation = ggplot(data_pref)+ geom_abline( intercept = c(0, 1, -1), slope = c(0, -1, 1), lty = 2, size = 0.4, col = "grey" )+ geom_jitter( aes( sP, sH, fill = comp_strat ), shape = 21, size = 3, alpha = 0.5 ) + scale_fill_discrete_qualitative( palette = "Set 2", order = c(2, 3, 1), labels = c( "Sc. 3: All consumers", "Sc. 2: Foragers", "Sc. 2: Kleptoparasites" ) )+ coord_cartesian( xlim = c(0, 0.03) ) + theme_test( base_size = 10 )+ theme( strip.background = element_blank(), strip.text = element_text( face = "italic" ), legend.position = "top" )+ facet_grid( cols = vars(rep), rows = vars(sim_type), labeller = labeller( rep = function(x) glue::glue("Rep: {x}"), sim_type = c( "obligate" = "Scenario 2", "facultative" = "Scenario 3" ) ) )+ labs( x = "sP: Prey-item preference", y = "sH: Handler preference", fill = NULL )+ guides( fill = guide_legend( override.aes = list( alpha = 1 ) ) ) # save figure ggsave( fig_variation, filename = "supplement/figures/fig_small_scale_variation.png", height = 4, width = 6 )
\newpage
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.