# Number of bird and mammal detections by method (observation, camera trap, eDNA)

library(ggplot2)
library(ggsci)

# Number of bird detections

bird_data <- read.csv("bird_detections.csv", header = TRUE)

p_bird <- ggplot(bird_data, aes(fill=Method, y=number, x=common_name)) + 
  geom_bar(position="stack", stat="identity") + 
  xlab("Taxa") +
  ylab("Number of detections") +
  scale_y_continuous(expand = c(0,0),
                     limits = c(0,65)) +
  scale_x_discrete(limits=c("Rufous hummingbird", "Broad-tailed hummingbird", "Sapsucker sp.", "Downy woodpecker", "Hairy woodpecker", "Corvidae sp.", "Chickadee sp.", "Ruby-crowned kinglet", "Wren sp.", "Nuthatch sp.", "Dark-eyed junco", "White-crowned sparrow", "Lincoln's sparrow", "Orange-crowned warbler", "Yellow-rumped warbler", "Wilson's warbler", "Black-headed grosbeak")) +
  theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
                     panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")) +
  theme(axis.text.x = element_text(colour = "black", angle = 45,vjust = 1, hjust = 1)) +
  theme(axis.text.y = element_text(colour = "black"))

p_bird + scale_fill_npg(name = "Detection method") + coord_flip()

# Number of mammal detections

mammal_data <- read.csv("mammal_detections.csv", header = TRUE)

p_mammal <- ggplot(mammal_data, aes(fill=Method, y=number, x=common_name)) + 
  geom_bar(position="stack", stat="identity") + 
  xlab("Taxa") +
  ylab("Number of detections") +
  scale_y_continuous(expand = c(0,0),
                     limits = c(0,40)) +
  scale_x_discrete(limits=c("Snowshoe hare", "American black bear", "Deer sp.", "Vole sp.", "Deer mouse sp.", "Western jumping mouse", "American red squirrel", "Chipmunk sp.")) +
  theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
                     panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")) +
  theme(axis.text.x = element_text(colour = "black", angle = 45,vjust = 1, hjust = 1)) +
  theme(axis.text.y = element_text(colour = "black"))

p_mammal + scale_fill_npg(name = "Detection method") + coord_flip()

