Import Data

players <- read_csv("ipl2026_players.csv")
players <- as_tibble(players)

Figure 1

fig1_data <- players %>%
  arrange(desc(AuctionPrice)) %>%
  slice(1:20)

ggplot(fig1_data, aes(x = reorder(PlayerName, AuctionPrice), 
                      y = AuctionPrice, fill = Team)) +
  geom_bar(stat = "identity") +
  coord_flip()

Figure 2

fig2_data <- players %>%
  group_by(Team, Role) %>%
  summarise(TotalSalary = sum(AuctionPrice, na.rm = TRUE), .groups = "drop")

ggplot(fig2_data, aes(x = Team, y = TotalSalary, fill = Role)) +
  geom_bar(stat = "identity")

Figure 3 (Interactive)

fig3_data <- players %>%
  filter(Role %in% c("Batsman", "All-Rounder"))

p <- ggplot(fig3_data, aes(x = AuctionPrice, y = RunsScored,
                          color = Team)) +
  geom_point()

ggplotly(p)

Figure 4

fig4_data <- players %>%
  group_by(Team, Nationality) %>%
  summarise(AverageSalary = mean(AuctionPrice, na.rm = TRUE), .groups = "drop") %>%
  pivot_wider(names_from = Nationality, values_from = AverageSalary)

ggplot(fig4_data, aes(y = Team)) +
  geom_point(aes(x = India)) +
  geom_point(aes(x = Overseas)) +
  geom_segment(aes(x = India, xend = Overseas, yend = Team))

Figure 5

ggplot(players %>% filter(!is.na(StrikeRate)),
       aes(x = StrikeRate, fill = Role)) +
  geom_density(alpha = 0.4)

Figure 6

fig6_data <- players %>%
  arrange(desc(WicketsTaken)) %>%
  slice(1:20)

ggplot(fig6_data, aes(x = reorder(PlayerName, WicketsTaken),
                      y = WicketsTaken)) +
  geom_col() +
  coord_flip()

Figure 7

fig7_data <- players %>%
  group_by(Team, Role) %>%
  summarise(Count = n(), .groups = "drop")

ggplot(fig7_data, aes(x = Team, y = Role, fill = Count)) +
  geom_tile()