LA-01

Author

Parth&Reshma

Question

Create a radial bar chart to show top 10 cities with highest air pollution levels

Step1:Load the require library

library(ggplot2)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(RColorBrewer)

Step2:Create the dataset

air_pollution <- data.frame(
  city = c("Byrnihat", "Delhi", "Lahore", "Hotan", "Faisalabad",
           "Ghaziabad", "Noida", "Baghpat", "Peshawar", "Lucknow"),
  pm25 = c(128.2, 110.2, 97.4, 94.3, 92.5, 91.3, 89.7, 88.1, 86.9, 85.4)
)

Step3:Arrange data by PM2.5 levels

air_pollution <- air_pollution %>%
  arrange(desc(pm25)) %>%
  mutate(city = factor(city, levels = city))

Step4:Create the radial bar chart

ggplot(air_pollution, aes(x = city, y = pm25, fill = city)) +
  geom_bar(stat = "identity", width = 1, color = "white") +
  coord_polar(theta = "x", start = 0) +
  theme_minimal() +
  labs(
    title = "Top 10 Most Polluted Cities (PM2.5 µg/m³, 2024)",
    subtitle = "Data Source: Visual Capitalist",
    x = NULL,
    y = NULL
  ) +
  theme(
    axis.text.y = element_blank(),
    axis.ticks = element_blank(),
    axis.text.x = element_text(size = 10, face = "bold"),
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5),
    plot.subtitle = element_text(size = 10, hjust = 0.5),
    legend.position = "none"
  ) +
  scale_fill_brewer(palette = "Set3")