## Select variables to exclude (the negative sign) ... this is not necessary, but
## it makes the data a little easier to look at.
## Convert month numbers to month abbreviation ... and order levels as factor
cb <- read.csv("CoralBleaching.csv",stringsAsFactors=FALSE) %>%
select(-ENTRY_CODE,-DATABASE_CODE,-NAME,-CITATION,-SOURCE,
-LATITUDE,-LONGITUDE) %>%
mutate(MONTH=month.abb[MONTH],MONTH=factor(MONTH,levels=month.abb))
str(cb)
mx <- read.csv("MXCoral.csv")
str(mx)
This coral bleaching data is from the Coral Bleaching Database. The data is an expansion of the voluntary Reefbase database of bleaching obdervations through a coral reef research and monitoring community. The data is from 1963 thorugh 2010 and the data comes from all over the world. The website I got my data from is https://figshare.com/projects/Coral_Bleaching_Database_V1/19753.
I limited my data to 2003-2006 and I looked at the months and the severity of bleaching. The severity is from -1 to 3, with -1 being unknown and 3 being greater than 50 percent bleached. I filtered out -1. I hypothesize that summer months are going to have a higher bleaching severity than winter months. Almost all the months fall in the severity code of 1. In May 2004, March, May, October, and November had a higher severity than July and August. In 2006, January through June had more consistant throughout each code. I choose a violin plot to see how much of the bleaching severity was ending up in each month. I also used geom jitter to see wehre most of the data was falling. I choose to fill the color in with the months and keep the defult colors because I like having each month colored. I choose to facet the years to see the bleaching severity by each year. In the caption I put the severity index to make sense of the numbers on the side of my graph. In both graphs I bolded the title and axis titles so it would stand out. I also put a dark gray fill in the facet titles to make it easier to read and see. Both graphs I has at least on of the axis to be free to better fit the data.
## Get just 2003-2006
cb1 <- filter(cb,YEAR>=2003,YEAR<=2006,MONTH!="NA",SEVERITY_CODE!=-1)
ggplot(data=cb1, mapping=aes(x=MONTH, y=SEVERITY_CODE, color=MONTH,fill=MONTH))+
geom_violin(trim=FALSE) +
geom_jitter(data=cb1,mapping=aes(x=MONTH,y=SEVERITY_CODE),width=0.07,
color="black",alpha=0.15,size=0.5)+
scale_x_discrete(name="Month")+
scale_y_continuous(name="Bleaching Severity") +
theme_bw()+
theme(plot.title=element_text(face="bold",size=rel(1)),
axis.title=element_text(face="bold",size=(10)),
panel.grid.major=element_line(color="gray90",size=rel(0.25)),
panel.grid.minor=element_blank(),
panel.spacing=unit(1,unit="mm"),
strip.background=element_rect(fill="gray20",color="gray20"),
strip.text=element_text(color="white",face="bold",size=rel(1),
margin=margin(t=1,b=1,r=1,l=1,unit="mm")),
legend.position="none")+
facet_wrap(vars(YEAR),scales="free_x")+
labs(title="Coral Bleaching Severity, 2003-2006",
caption="Source: https://figshare.com/projects/Coral_Bleaching_Database_V1/19753")
I created a new csv file of the country, depth, severity, and percent bleached because the data for depth and percent bleached was entered in different ways. This data is looking at percent bleached and depth in Mahahual, Mexico; Pez Maya Reserva dela Biosfera, Mexico; Florida Keys, Florida; Broward, Florida; Palm Beach, Florida; and Northern Trans, Florida. I hypothesize that coral at a lesser depth is going to have a higher percentage of bleaching than coral at a deeper depth. Florida Keys had a more coral beached at a smaller depth than it did at a deeper depth. Coral between 20 and 50 percent in Mexico and mainland Florida there were no significant between the depth and the percent bleached. Mainland Florida at a depth between 10 and 15 meters have a decrease in the bleached percentage. I choose to do a facet grid to look at the data by country and by the severity to see where better see what percent the coral was bleached. I choosed colorblind friendly colors for the points and a gray regession line.
mx1 <- filter(mx, Severity!=-1)
ggplot(data=mx1,mapping=aes(y=Percent,x=Depth,color=Country,fill=Country)) +
geom_point(size=2,pch=21, alpha=0.5) +
geom_smooth(method="lm",se=FALSE,color="gray") +
scale_x_continuous(name="Depth of Coral (m)") +
scale_y_continuous(name="Percent Bleached") +
scale_color_manual(values=c("orange","skyblue","aquamarine4"))+
scale_fill_manual(values=c("orange","skyblue","aquamarine4"))+
theme_bw()+
theme(panel.grid.minor=element_blank(),
panel.grid.major=element_blank(),
legend.position="none",
plot.title=element_text(face="bold",size=rel(1)),
axis.title=element_text(face="bold",size=(10)),
panel.spacing=unit(1,unit="mm"),
strip.background=element_rect(fill="gray20",color="gray20"),
strip.text=element_text(color="white",face="bold",size=rel(1),
margin=margin(t=1,b=1,r=1,l=1,unit="mm")))+
facet_grid(rows=vars(Severity),cols=vars(Country),scales="free",
labeller=labeller(Severity=c("1"="1 - 10%","2"="11 - 50%","3"=">50%")))+
labs(title="Precent of Coral Bleached by Depth of Coral")