YAY GRAPHS! Using the airquality dataset from R, that has info about air quality measurements in New York City.
ggplot template (for my brain)
p1 <- ggplot(data= <DATA>) +
aes(<MAPPINGS>) +
<GEOM_FUNCTION>(aes(<MAPPINGS>),
stat=<STAT>,
position=<POSITION>) +
<COORDINATE_FUNCTION> +
<FACET_FUNCTION>
# loading things area
library(ggplot2)
library(beeswarm)
library(ggbeeswarm)
## Warning: package 'ggbeeswarm' was built under R version 4.1.2
library(RColorBrewer)
## Warning: package 'RColorBrewer' was built under R version 4.1.2
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.1.2
data(airquality)
head(airquality)
## Ozone Solar.R Wind Temp Month Day
## 1 41 190 7.4 67 5 1
## 2 36 118 8.0 72 5 2
## 3 12 149 12.6 74 5 3
## 4 18 313 11.5 62 5 4
## 5 NA NA 14.3 56 5 5
## 6 28 NA 14.9 66 5 6
Beeswarm Plot! bzzzzzzzzz
# had a lot of trouble since month is technically a numeric value, but here is how to turn it into a factor
airquality$Month <- factor(airquality$Month)
ggplot(airquality,aes(x=Month, y=Wind, color=Month)) +
geom_beeswarm()+
scale_color_manual(values = c("olivedrab3","gold","orange2","red1","darkred"))+
ggtitle("Windspeed Variation in New York City Based on Month")
Making a plot with some of my very initial data
data <- read.csv("NLPsheet2.csv")
ggplot(data=data,aes(x=Date, y=Total_NLPs)) +
geom_beeswarm()
I think this is kinda the wrong graph type for this data right now though!
Bar Plot of NLPs
ggplot(data, aes(x = Behavior, y = Total_NLPs, fill = Behavior)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("#ffffcc", "#a1dab4", "#41b6c4","#2c7fb8", "#225ea8")) +
ggtitle("Presence of NLPs Dependent on Dolphin Behavior")
other plots that I made for my committee meeting, with updated data
# --------- BEHAVIOR BAR PLOT ----------
ggplot(data, aes(x = Behavior, y = Total_NLPs, fill = Behavior)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("#ffffcc", "#c7e9b4", "#a1dab4", "#41b6c4","#2c7fb8", "#225ea8"))
# -------------------- NLP Bar Plot------
# Reshape the data from wide to long format
Collect_NLP <- gather(data, key = "category", value = "value", BP, DC, SB, SH)
# Create the bar plot
ggplot(Collect_NLP, aes(x = category, y = value, fill = category)) +
geom_bar(stat = "identity") +
scale_fill_manual(values=c("#c7e9b4","#a1dab4","#41b6c4","#225ea8"))+
labs(title = "Total Presence of NLPs: June 2023",
x = "NLP Type",
y = "Total Appearances") +
theme_minimal()
# ------------- Group Size v Whistle Numbers Comparison ------------
# Scatter plot
scatter <- ggplot(data, aes(x = Group_Size, y = Total_NLPs)) +
geom_point() +
geom_smooth(method="lm", color="red", se=FALSE) +
labs(title = "Group Size v. NLP Totals",
x = "Group Size",
y = "Number of NLPs") +
theme_minimal()
scatter
## `geom_smooth()` using formula = 'y ~ x'