Plot with multiple y axis

Hi everyone.

I try to remake the same plot as the image but i can´t.
Hope you can help me

Cheers.

This the code for the dataframe:
serie <-
tribble(~nom_oms, ~estim, ~muertes, ~contam, ~valor,
"NOM", "NOM-10", 70455, "PM[2.5]", "10 µg/m³",
"OMS", "OMS-5", 96921, "PM[2.5]", "5 µg/m³",
"NOM", "NOM-36", 25966, "PM[10]", "36 µg/m³",
"OMS", "OMS-15", 87045, "PM[10]", "15 µg/m³",
"NOM", "NOM-40", 15010, "NO[2]", "0.021 ppb",
"OMS", "OMS-10", 66087, "NO[2]", "0.005 ppb",
"OMS", "OMS-60", 45114, "O[3]", "0.031 ppb") %>%
print()

I think this gives you most of what you want.

library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.3

serie <-
  tribble(~nom_oms, ~estim, ~muertes, ~contam, ~valor,
          "NOM", "NOM-10", 70455, "PM[2.5]", "10 µg/m³",
          "OMS", "OMS-5", 96921, "PM[2.5]", "5 µg/m³",
          "NOM", "NOM-36", 25966, "PM[10]", "36 µg/m³",
          "OMS", "OMS-15", 87045, "PM[10]", "15 µg/m³",
          "NOM", "NOM-40", 15010, "NO[2]", "0.021 ppb",
          "OMS", "OMS-10", 66087, "NO[2]", "0.005 ppb",
          "OMS", "OMS-60", 45114, "O[3]", "0.031 ppb") 

serie |> mutate(X_Labs = paste0(nom_oms, "\n", valor)) |> 
  ggplot(aes(x = X_Labs, y = muertes)) + 
  geom_col(fill = "steelblue", width = 0.4) +
  geom_text(aes(label = muertes), hjust = 1,vjust = -1.3) +
  labs(x = "", y = "") +
  coord_flip() +
  facet_grid(rows = vars(contam), scales = "free_y",  space = "free") 

Created on 2024-08-19 with reprex v2.0.2

1 Like

This topic was automatically closed 7 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.