I need to create a unique box plot. I want it to represent the geometric mean instead of the median, and the top and bottom of the box to be the 90th and 10th percentiles. I have found information on how to add means and sd and how to extend wiskers on plots but not how to change the basic statistics. I would like to use ggplot2 because I'm familiar with it but I'm open to anything.
I'm plotting fecal coliform data by year with the following code:
library(psych)
library(dplyr)
library(zoo)
library(caTools)
library(ggplot2)
library(stats)
setwd("H:/MWQSampleData/GrowingAreaRawData")
setAs("character", "myDate", function(from) as.Date(from, format = "%m/%d/%Y"))
RawData <- read.csv("VaughnBay1989.csv", header = TRUE, colClasses =
c("factor", "factor", "myDate", "numeric", "factor", "numeric", "numeric","numeric"))
GrowingAreaYrSummary <- RawData %>%
select(Year, FecalColiform) %>%
group_by(Year)
Graph <- ggplot(GrowingAreaYrSummary, aes(x=Year, y=FecalColiform))
geom_boxplot(outlier.shape = NA) +
theme(axis.text.y = element_text(face = "bold", angle = 45, size = 14),
axis.text.x = element_text(face = "bold", angle = 45, size = 14, vjust = -0.005),
panel.background = element_rect(fill = "ivory2"),
panel.grid.major = element_line(colour = "gray88"),
plot.title = element_text(size = 18, face = "bold", vjust = -4),
axis.title.y = element_text(size = 16, face = "bold"),
axis.title.x = element_text(size = 16, face = "bold", vjust = -0.5),
axis.ticks.x = element_line(size = 1.5, colour = "black"),
panel.border = element_rect(colour = "black", fill = NA, size = 1)) +
scale_y_continuous(breaks=seq(0,50,5), limits=c(0,50)) +
geom_smooth(method="loess", se="TRUE", aes(group=1)) +
ggtitle("Vaughn Bay Growing Area \n Fecal Coliform 1989 - 2015") +
ylab("Fecal Coliform (fc/100 ml)") +
xlab("Year") +
annotate("text", x=10, y=43, label="Outliers Excluded \n from Graph")
Graph
I would like to make the same graph but with the new components. Any insight is appreciated. Thank you!