library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(dplyr)
library(ggplot2)

#Chart 1

pollinate_data <- data.frame(Crop = c("Grains", "Cotton", "Apples & Pears", "Almonds", "Avocado", "Blueberries", "Macadamia", "Raspberries & Blackberries", "Cherries"), Value_M = c(11400, 2500, 494, 441, 350, 244, 242, 176, 159), Dependance_lvl = c("Moderate", "Moderate", "High", "Very High", "Very High", "Very High", "High", "Very High", "Very High"))

p_data <- pollinate_data %>% 
  arrange(Value_M) %>% 
  mutate(Crop = factor(Crop, levels = Crop))

plot <- ggplot(
  p_data, 
  aes(
    x=Value_M,
    y=Crop,
    colour=Dependance_lvl,
    text=paste(
      "Crop: ", Crop,
      "<br>Industry Value:", Value_M, "M",
      "<br>Pollination Dependance: ", Dependance_lvl)
   )
  ) + 
    geom_segment(aes(x=0, xend=Value_M, y = Crop, yend= Crop), linewidth = 0.8) +
    geom_point(size = 3) +
    scale_x_log10() +
    labs(
      title = "Australian Depends on Pollinators More Than People Realise",
      x = "Industry Value (M)",
      y = NULL,
      colour = "Pollination Dependance"
    ) + 
    theme_classic() +
    theme(plot.title = element_text(hjust = 0.5))

ggplotly(plot, tooltip = "text")
## Warning in scale_x_log10(): log-10 transformation introduced infinite values.

#Chart 2 #Managed Bee Hives by State.

bee <- data.frame(state = c("NSW", "QLD", "VIC", "WA", "SA", "TAS", "NT", "ACT"), hives = c(394112, 154872, 130611, 55020, 86000, 29723, 2762, 2230))

bee <- bee %>% mutate(share = hives / sum(hives) * 100)

bee_plot <- ggplot(bee, aes(x = reorder(state, share), y = share)) + 
  geom_col(fill = "sienna3") + 
  geom_text(
    aes(label = paste0(round(share, 1), "%")), 
    hjust = -0.2, 
    size = 3, 
    fontface = "bold"
  ) + 
  coord_flip() + 
  labs(
    title = "Distribution of Managed Bee Hives in Australia", 
    x = "State", 
    y = "Share of Hives (%)"
   ) + 
   scale_y_continuous(
     expand = expansion(mult = c(0,0.15))
   ) + 
   theme_classic() + 
   theme(plot.title = element_text(hjust = 0.5))

bee_plot

#Chart 3 #Australian Bee Colony Loss by Season

bee_data3 <- data.frame(yr = c("2024","2024","2024","2024","2025","2025","2025","2025"), season = c("Warm","Warm","Cool","Cool","Warm","Warm","Cool","Cool"),hive_type = c("Amateur","Commercial","Amateur","Commercial", "Amateur","Commercial","Amateur","Commercial"), b_loss = c(11.3, 7.3, 7.6, 6.1, 16.2, 12.6,9.0, 8.1))


bee_3 <- ggplot(bee_data3, aes(x = season, y = b_loss, fill = hive_type)) + geom_col(position = "dodge") + geom_text(aes(label = paste0(b_loss, "%")), position = position_dodge(width = 0.9), vjust = -0.3, fontface = "bold", size = 3) + facet_wrap(~yr) + scale_fill_manual(values = c("Amateur" = "sienna3", "Commercial" = "darkolivegreen")) + labs(title = "Australian Bee Colony Losses in Recent Years", subtitle = "Losses are increasing and are higher during the warmer seasons.", x = "Season", y = "Loss (%)", fill = "Hive Type") + theme_classic() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5)) 

bee_3

#Chart 4

chart_4 <- data.frame(state= c("NSW","QLD","VIC","WA","SA","TAS","NT","ACT"), land_2010 = c(88300, 370900, 16300, 68700, 11500, 16200, 4800, 1500), land_2018= c(574700, 2075700, 161600, 219700, 97200, 50300, 27000, 1500), hive_no= c(394264,159644,130227,58801,86000,32117,2762,2230))

chart4 <- ggplot(chart_4, aes(y = reorder(state, land_2018), text=paste("Land Cleared 2010: ", land_2010,"ha", "<br>Land Cleared 2018: ", land_2018, "ha", "<br>State: ", state))) + geom_segment(aes(x = land_2010, xend = land_2018, yend = state), colour = "grey60", linewidth = 1) + geom_point(aes(x = land_2010), colour = "darkolivegreen", size = 5) + geom_point(aes(x = land_2018), colour = "red4", size = 5) + geom_text(aes(x = land_2018, label = paste0("Hives: ", format(hive_no, big.mark = ","))), nudge_y = 0.4, nudge_x= -0.4, hjust = -0.5, size = 3) + labs(title = "Land Clearing by Australian State Against No. of Commercial Bee Hives", subtitle= "2010 vs 2018", x = "Clearing (Hectares)", y = "State") + theme_classic() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5, face= "italic")) + scale_x_log10() + coord_cartesian(clip = "off") + theme(plot.margin = margin(20, 80, 20, 20))

ggplotly(chart4, tooltip = "text")

#Chart 5 #Data Sourced From Australian Honey Bee & Pollination Industry National Colony Loss Survey - 2024 & 2025 Key Results.

chart_5 <- data.frame(labels = c("WA", "WA", "SA", "VIC", "TAS", "NSW", "NSW", "QLD", "QLD"), percent = c(3, 2.6, 4.2, 3.3, 7.1, 3.6, 3.4, 4, 1.6), cause = c("Starvation", "Queen Failure", "Starvation", "Queen Failure", "Queen Failure", "Queen Failure", "Varroa", "Queen Failure", "Small Hive Beetle"))

chart5_plot <- ggplot(chart_5, aes(x = reorder(labels, percent), y = percent, fill=cause, text=paste("State: ", labels, "<br>Percentage Loss: ", percent, "(%)", "<br>Cause: ", cause))) + geom_col() + coord_flip() + labs(title= "Reported Major Causes of Bee Colony Loss by State", y = "Reported Percentage Loss (%)", x = "State") + scale_y_continuous(expand = expansion(mult = c(0,0.25))) + theme_classic() + theme(plot.title = element_text(hjust = 0.5)) + theme(plot.subtitle = element_text(hjust = 0.5))

ggplotly(chart5_plot, tooltip = "text")