adding third variable to bar columns

How can I add a third variable to a bar plot? I'm new to R so tidyverse and ggplot is still a bit confusing for me.

library(tidyverse)
library(plotly)
library(stringr)

fines %>% 
  filter(IF_SPEEDING == "Y" & LOCATION != "" & SPEED_BAND != "") %>%
  group_by(LOCATION) %>%
  summarise(
    `Number LOCATION` = n()
  ) %>%
  arrange(
    -(`Number LOCATION`)
  ) %>%
 filter( `Number LOCATION` > 800) -> LOCATION_OVER_800

LOCATION_OVER_800 %>%
    ggplot(aes(x = LOCATION, y = `LOCATION_OVER_800` )) + 
    geom_bar(aes(fill=SPEED_BAND), stat = "identity") +
    theme(axis.text.x = element_text (angle = 45)) +
    labs(
      title = "Locations of issued fine and speeding severity",
      x = 'Location', 
      y = 'Number of fines'
    ) -> p

ggplotly(p)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.