errorPlot <- function(errors, metric, unit) { library("ggplot2") minInd <- which.min(errors) # ggplot format plotstyle <- theme(plot.title = element_text(size=20, hjust = 0.5, face="bold"), axis.title.x = element_text(size=14, face="bold"), axis.title.y = element_text(size=14, face="bold")) ggplot(NULL, aes(x=mass[(minInd-50):(minInd+50)], y=errors[(minInd-50):(minInd+50)])) + geom_point(shape=1, color="red") + geom_line(color="red") + geom_vline(xintercept = mass[minInd], color = "blue") + geom_text(aes(x=(mass[minInd]+0.1), y= (errors[minInd]-0.2)),label=toString(mass[minInd]),hjust=0, size=9) + labs(title = paste0(metric," between measured and computed power"), x = "Weight (kg)", y = paste0(metric," (",unit,")")) + # scale_x_continuous(limits = c(82, 94)) + # scale_y_continuous(limits = c(38.5, 41)) + plotstyle }