####################################################################################################################################################################### ### Script for morphological data treatment and plotting ### ### Written by V. Fischer, P. Wintgens, Feb 2025 ### ### Associated paper: Fischer, Weis et al. Vampyromorph coleoid predation by an ichthyosaurian from the Early Jurassic Lagerstätte of Bascharage, Luxembourg. PeerJ ### ####################################################################################################################################################################### ### Packages library(ggplot2) library(readxl) library(tidyr) library(viridis) ### Get and tidy data raw_data <- read_excel("morpho_data.xlsx",na="NA",sheet="Dataset") #raw_data$Total_length <- log(raw_data$Total_length) #log transforms body length, if needed data <- pivot_longer(raw_data,!Species, names_to="Trait", values_to="Value") data$Trait <- factor(data$Trait, levels=colnames(raw_data)[-1]) ### Make the barplots clade_colors<-c("#25BA8C", viridis(n=7, option="E")[c(6, 5)]) barplot(rep(1, length(clade_colors)), col=clade_colors, border=NA, space=0) #visualise the colors names(clade_colors)<-raw_data$Species #"Stenopterygius_triscissus","Pachycormus_macropterus","Saurostomus_esocinus" ggplot(data,aes(x=Species, y=Value,fill=Species)) + geom_col() + facet_wrap(~Trait, scales="free_x",ncol=1)+ scale_fill_manual(values=clade_colors)+ coord_flip()+ xlab("")+ ylab("")+ ggtitle(label="Comparison of functional traits")+ theme(panel.grid=element_blank(), panel.background=element_rect(fill="white"), axis.text.y=element_blank(), axis.ticks.y=element_blank(),strip.background=element_rect(fill="white"), legend.position="bottom") #theme_void() ggsave("morpho_data.pdf",device="pdf",width=90,height=250,units="mm")