Load packages
libs <- c('tidyverse')
lapply(libs, require, character.only = TRUE)
Import and log-transform morphological data
morpho_all <- read.table('data/morphology/morpho_pristurus.csv', sep = ';', 
                         dec = '.', header = TRUE)

morpho_all_log <- morpho_all %>%
  mutate(across(where(is.numeric), log10))
Set the theme
theme.clean <- function(){
  theme_minimal() +
    theme(axis.text.x = element_text(size = 10, angle = 45, vjust = 1, hjust = 1),
          axis.text.y = element_text(size = 12),
          axis.title.x = element_text(size = 14, face = "plain"),             
          axis.title.y = element_text(size = 14, face = "plain"),             
          #          panel.grid.major.x = element_blank(),                                          
          #          panel.grid.minor.x = element_blank(),
          #          panel.grid.minor.y = element_blank(),
          #          panel.grid.major.y = element_blank(),  
          plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), units = , "cm"),
          plot.title = element_text(size = 20, vjust = 1, hjust = 0.5),
          legend.text = element_text(size = 12, face = "plain"),          
          legend.position = "right")
}
Set the colors
habitat_broad_colors0 <- c(ground = 'brown', rock = 'gray', tree = 'darkgreen')
habitat_broad_colors <- c(ground = '#e0710b', rock = '#6C586E', tree = '#119616')
habitat_colors0 <- c('hard-ground' = 'brown', 'soft-ground' = 'orange', 
                    rock = 'gray', tree = 'darkgreen')
habitat_colors <- c('hard-ground' = '#D63916', 'soft-ground' = '#E9A800', 
                    rock = '#6C586E', tree = '#119616')
land_colors0 <- c(mainland = 'coral2', island = 'seagreen')
land_colors1 <- c(mainland = '#A54E29', island = '#42978A')
land_colors2 <- c(mainland = '#C56542', island = '#67D1B7')
land_colors <- c(mainland = '#C56542', island = '#42978A')

ORDERED BOXPLOTS

Boxplot insularity

# Order the species by mailand/island and by SVL
namevec_island <- arrange(morpho_all_log, land, SVL) %>%
  pull(species) 
morpho_all_log$species <- factor(morpho_all_log$species, level = unique(namevec_island))

boxplot_land <- ggplot(morpho_all_log) +
  geom_boxplot(aes(x = species, y = SVL, fill = land)) +
  scale_fill_manual(values = land_colors) +
  theme.clean() +
  theme(legend.position = 'right') +
  ylab("log(SVL)")

# Plot
boxplot_land

Boxplot habitat (broad)

# Order the species by habitat broad and by SVL
namevec_habitat_broad <- arrange(morpho_all_log, habitat_broad, SVL) %>%
  pull(species) 
morpho_all_log$species <- factor(morpho_all_log$species, level = unique(namevec_habitat_broad))

boxplot_habitat_broad <- ggplot(morpho_all_log) +
  geom_boxplot(aes(x = species, y = SVL, fill = habitat_broad)) +
  scale_fill_manual(values = habitat_broad_colors) +
  theme.clean() +
  #  theme(legend.position = 'none') +
  theme(legend.position = 'right') +
  ylab("log(SVL)")

# Plot
boxplot_habitat_broad

Boxplot habitat

# Order the species by habitat and by SVL
namevec_habitat <- arrange(morpho_all_log, habitat, SVL) %>%
  pull(species) 
morpho_all_log$species <- factor(morpho_all_log$species, level = unique(namevec_habitat))

boxplot_habitat <- ggplot(morpho_all_log) +
  geom_boxplot(aes(x = species, y = SVL, fill = habitat)) +
  scale_fill_manual(values = habitat_colors) +
  theme.clean() +
  theme(legend.position = 'right') +
  ylab("log(SVL)")

# Plot
boxplot_habitat

Conclusion

We see that island species do not present more size variability than mainland species. On the contrary, habitat occupancy seems to provide more insight about size variation. Ground species present the highest disparity in size, being the smallest and the largest Pristurus species. Further, the subdivision of the ground habitat in “hard ground” and “soft-ground” allows us to perceive that hard-ground species have specialized by developing a large size, while soft-ground species have reduced their size. Additionally, we found what it seems a constrained size in tree species, which may be indicating a selective pressure imposed by this habitat.