# mirror.barplot - mirrored barplot for comparing positive and negative changes in a variable

The code for this function can be found here.

The arguments to pass to the function are:

• lower.vals - A numeric vector or a column of a matrix or data.frame
• upper.vals - A numeric vector or a column of a matrix or data.frame
• cols - A character vector of length 2 corresponding to the colors for the upper and lower values respectively
• bar.width - numeric value for width of the bars
• bar.spacing - numeric value for the amount of space between bars
• upper.y.text - A character or expression to be plotted next to the upper values
• lower.y.text - A character or expression to be plotted next to the lower values
• y.lab.offset - numeric value for the y label offset
• y.lab.cex - numeric size of the y label
• margins - numeric vector for plotting margins

To demonstrate this function I will use data comparing the climatic conditions of invasive ranges of species to that of their native ranges (N. Crouch, unpublished data)

# The function
source("mirror.barplot.R")

# The data
dat <- read.csv("analysis_data.csv")

I will first calculate whether the temperature of the invasive ranges exceeds that of the native ranges

# Lower minimum temperature in invasive range
tMin <- dat$Native_Temp_Min - dat$Invasive_Temp_Min
tMin[tMin < 0] <- 0
dat$TempMinIncrease <- tMin # Higher maximum temperature in invasive range tMax <- dat$Invasive_Temp_Max - dat$Native_Temp_Max tMax[tMax < 0] <- 0 dat$TempMaxIncrease <- tMax

Now the plot can be generated:

mirror.barplot(lower.vals = dat$TempMinIncrease, upper.vals = dat$TempMaxIncrease, upper.y.text = "Increase in Maximum Temperature", lower.y.text = "Increase in Minimum Temperature", cols=c("#0072B2", "#D55E00"), margins=c(0.05,0.75,0.05,0.1), y.lab.cex=0.6)

Each column in the plot represents a single species. The orange values below the line show where the minimum temperature in the invasive range exceeds that of the native range. The blue values show where the maximum temperature of the invasive range is greater than that of the native range.