data = fread("data/data_lt_plot.csv")[growth %in% c(0.01) & interval %in% c(3, 6),] # select 2 agents per strategy data[, uid := id %in% first(unique(id)), by = c("growth", "type", "move_strategy", "comp_strat")] data = data[(uid),] # remove some strategies data = data[ (type == "exploit" & (move_strategy %in% c( "prey tracking", "prey and handler tracking", "non-handler avoiding", "handler tracking"))) | (type == "obligate" & (move_strategy %in% c( "non-handler avoiding", "handler avoiding", "handler tracking"))) ] # remove manually data = data[!(comp_strat == "klept" & move_strategy == "handler avoiding")] data = data[type != "interf"]
data = split(data, by = "type") plot_move = lapply(data, function(df) { ggplot(df)+ geom_path( aes( x_wrap, y_wrap, group = interaction(id, interval, growth, rep_), col = move_strategy ), show.legend = F )+ scale_colour_manual( values = c( "prey tracking" = "darkgreen", "prey and handler tracking" = "darkblue", "non-handler avoiding" = "red", "handler avoiding" = "orange", "handler tracking" = "steelblue" ), breaks = c( "prey tracking", "handler tracking", "prey and handler tracking", "non-handler avoiding", "handler avoiding" ) )+ facet_wrap( comp_strat ~ interval, labeller = labeller( .multi_line = F, move_strategy = c( "prey tracking" = "Prey tracking", "handler tracking" = "Handler tracking", "prey and handler tracking" = "Prey & handler tracking", "non-handler avoiding" = "N. handler avoiding", "handler avoiding" = "Handler avoiding" ), growth = label_both, interval = c( "3" = "T: 3,000 - 4,000", "6" = "T: 6,000 - 7,000" ) ) )+ theme_minimal(base_size = 10)+ theme( legend.position = "top", strip.text = element_text( face = "italic" ), legend.text = element_text(size = 8), legend.title = element_text(size = 8), # legend.key.width = unit(2, "mm"), legend.key.height = unit(2, "mm"), strip.background = element_blank(), axis.title = element_blank(), # axis.ticks = element_blank(), panel.grid.minor = element_blank(), panel.grid.major = element_line( linetype = 1, size = 0.2 ), panel.border = element_rect( colour = "grey20", fill = NA, size = 0.1 ) )+ coord_equal( # xlim = c(-60, 60), # ylim = c(-60, 60) )+ guides( colour = guide_legend(override.aes = list( size = 2 ) # nrow = 2, byrow = T, ncol = 2 ) )+ labs( colour = NULL ) }) plot_move = wrap_plots( plot_move, guides = "collect", ncol = 1, design = "AA\nBB\nBB" ) + plot_layout(tag_level = "new")& theme(legend.position = "top")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.