x <- getURL("https://raw.githubusercontent.com/karolo89/Raw_Data/main/Hurricane.csv")
hurricane <- read.csv(text = x)
head(hurricane)
## year num_hurricanes num_major_hurricanes type average
## 1 1851 3 1 avg_h_15year NA
## 2 1851 3 1 avg_mh_15year NA
## 3 1852 5 1 avg_h_15year NA
## 4 1852 5 1 avg_mh_15year NA
## 5 1853 4 2 avg_h_15year NA
## 6 1853 4 2 avg_mh_15year NA
graph1 <- ggplot(hurricane, aes(year,average, color = type)) +
geom_step(size=.7) +
## Adding the text
geom_textline(aes(label = ifelse(type == "avg_h_15year",
"All Hurricanes",
"Major Hurricanes"),
y = average + .8),
text_smoothing = 50,
fontface = 2,
hjust = 0,
linetype = 0,
size = 3) +
annotate("text", x = 1886, y = 2.2, label = "Category 3 - 5", hjust = 0,
color = "#3b2d74", size= 2.5) +
## Scales
scale_x_continuous(breaks = seq(1860,2020,20)) +
scale_y_continuous(limits = c(0,8.5),
breaks = seq(2,8,2),
expand = c(0,0)) +
scale_color_manual(values = c("#735ad2", "#3b2d74")) +
## Labs
labs(
y = " ",
x = " ",
title = "15-year average recorded Atlantic basin hurricanes, 1851-2019") +
## Theme
theme_minimal() +
theme(
panel.grid.minor = element_blank(),
panel.grid.major.x = element_blank(),
## Customize x axis
axis.ticks.x = element_line(colour = "#e1e1e1"),
axis.ticks.length.x =unit(0.3,"cm"),
axis.line.x.bottom = element_line(colour = "#313131"),
## axis text
axis.text = element_text(size= 6, color= "#8f8f8f",
face = "bold"),
## We don't want a legend
legend.position = "none",
## title
plot.title = element_text(size =8, face = "bold", colour= "#545454",
hjust = 0.50, vjust = 1)
)
graph1
I used the https://imagecolorpicker.com/en tool to get the hex colors from the graph