######################################################
#
# Bee castes relative abundance
#
######################################################

#### ROSALIND'S ATTEMPT ####

## Create a list of the values for all 3 castes:
queen<-c(59.6,5.4,8.7)
workers<-c(40.4,94.6,77.4)
males<-c(0,0,13.9)

## Join these together into one dataset:
castes <- rbind(queen,workers,males)

## Install and activate packages for accessible colour palette:
install.packages("viridisLite")
install.packages("viridis")
library(viridisLite)
library(viridis)

## Plot a stacked bar chart:
barplot(castes, 
        names.arg=c("June", "July", "August"),
        ylab="% trapped individuals", xlab="Month", ylim=c(0,100),
        col=viridis(3))

## Add a legend:
legend("top",inset=-0.2,horiz=TRUE,legend=c("Queen","Worker","Male"),
       fill=viridis(3),cex=0.8,xpd=TRUE,bty="n")

#### GRAEME'S ATTEMPT ####

queens<-c(59.6,5.4,8.7)
workers<-c(40.4,94.6,77.4)
males<-c(0,0,13.9)

castes <- rbind(queens,workers,males)
cols <- c("firebrick1","cornflowerblue","gold")

barplot(castes, names.arg=c("June", "July", "August"),
        ylab="fraction trapped (%)", xlab="Month", ylim=c(0,100),
        xlim = c(0,5), col=cols)

abline(h=0, lty=1)
legend("right",legend=c("Queen","Worker","Male"),
       fill=cols, bty = "n")

######################################################
#
# Alzheimer's deaths
#
######################################################

#### ROSALIND'S ATTEMPT ####

## Create a list of the values:
deaths<-c(146.2,1.5,1.3,-7.8,-11.8,-62.5)

## Install and activate package for minor tick marks:
install.packages("Hmisc")
library(Hmisc)

## Set y-axis, add grid lines, and minor ticks:
barplot(deaths, ylim=c(-100,150),las=1)
abline(h=(seq(-100,150,10)), col="lightgray", lty=1)
abline(h=(seq(-100,150,50)), col="darkgray", lty=1)
abline(h=0, col="slategray", lty=1, lwd=2)

minor.tick(ny=5, nx=0, tick.ratio=0.5)

## Draw a bar chart with some colour over the top: 
par(new=TRUE)
barplot(deaths, col="firebrick",ylim=c(-100,150),las=1,
        names.arg=c("Alzheimer's\ndisease", "Breast\ncancer", "Prostate\ncancer",
                    "Heart\n disease", "Stroke","HIV"),
        ylab="% change", xlab="Cause of death",cex.names=0.9)

#### GRAEME'S ATTEMPT ####

deaths<-c(146.2,1.5,1.3,-7.8,-11.8,-62.5)

barplot(deaths, 
        ylim=c(-100,150),las=1)
abline(h=(seq(-100,150,10)), col="lightgray", lty=1)
abline(h=(seq(-100,150,50)), col="darkgray", lty=3)
abline(h=0, col="darkgray", lty=1, lwd=3)

par(new=TRUE)
barplot(deaths, 
        col=c("firebrick1","cornflowerblue","cornflowerblue","cornflowerblue","cornflowerblue","cornflowerblue"),
        ylim=c(-100,150),las=1,
        names.arg=c("Alzheimer's", "Breast \ncancer", "Prostate \ncancer",
                    "Heart \ndisease", "Stroke","HIV"), cex.names = 0.75,
        ylab="% change 2018 vs 2000", xlab="Cause of death")
