Add secondary axis

Hello,
With this dataset I made this geom_col but I would like to add as a secondary axis (on the left) my depths with geom_line to have points corresponding to each of the depths and also a line that connects all the points and therefore crosses the whole chart !

How can I do ?

df <- tribble(
  ~zone, ~type, ~station, ~species, ~number, ~depth
  'A1', 'Adult', 1, 'Atlanticus', 2, 200,
  'A1', 'Adult', 1, 'Olrikii', 1, 450,
  'A1', 'Larvae', 2, 'Medius', 5, 345,
  'A2', 'Larvae', 1, 'Glacialis', 7, 269,
  'A2', 'Larvae', 2, 'Unidentified', 3, 405, 
  'A2', 'Adult', 2, 'Glacialis', 2, 380,
  'A2', 'Larvae', 2, 'Medius', 4, 310,
  'A3', 'Zoo', 1, 'Capilatta', 17, 290,
  'A3', 'Adult', 3, 'Olrikii', 1, 410
)

df %>% group_by(zone) %>% mutate(Percent = 100 * number/sum(number)) %>% 
  ggplot(aes(zone, y = Percent, fill = species)) + geom_col(position = "dodge")

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.