library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.6.1
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.6.1
##
## 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
data <- read.table(file.choose(), header = TRUE, sep = "\t")
data_top_bottom <- data %>%
arrange(desc(AKK)) %>%
mutate(Kategori = case_when(
row_number() <= 3 ~ "3 Teratas",
row_number() > (n() - 3) ~ "3 Terbawah",
TRUE ~ "Lainnya"
)) %>%
filter(Kategori != "Lainnya")
ggplot(data_top_bottom, aes(x = reorder(Provinsi, AKK), y = AKK, fill = Kategori)) +
geom_col(width = 0.6) +
scale_fill_manual(values = c("3 Teratas" = "#d73027", "3 Terbawah" = "#4575b4")) +
geom_text(aes(label = sprintf("%.2f", AKK)),
hjust = -0.2, size = 3.8, fontface = "bold") +
coord_flip() +
scale_y_continuous(limits = c(0, max(data_top_bottom$AKK) + 1.5), expand = c(0, 0)) +
labs(
title = "3 Provinsi Teratas & Terbawah Berdasarkan AKK",
subtitle = "Hasil SUPAS",
x = "Provinsi",
y = "Angka Kematian Kasar (per 1.000 Penduduk)",
fill = "Kategori"
) +
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold", size = 14),
panel.grid.major.y = element_blank(),
legend.position = "top"
)

ggplot(data, aes(x = "", y = AKK)) +
geom_boxplot(fill = "#d73027", width = 0.3, outlier.color = "black", outlier.size = 2) +
labs(
title = "Box Plot AKK Indonesia Hasil SUPAS",
x = "",
y = "Angka Kematian Kasar (AKK)"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, face = "bold", size = 14)
)

library(ggplot2)
library(dplyr)
data <- read.table(file.choose(), header = TRUE, sep = "\t")
kalimantan_df <- data %>%
filter(grepl("^KALIMANTAN", Provinsi))
ggplot(kalimantan_df, aes(x = reorder(Provinsi, AKK), y = AKK)) +
geom_segment(aes(xend = Provinsi, y = 0, yend = AKK), color = "#2b5c8f", size = 1) +
geom_point(color = "#08306b", size = 4) +
geom_text(aes(label = sprintf("%.2f", AKK)), vjust = -1, size = 3.8, fontface = "bold") +
scale_y_continuous(limits = c(0, max(kalimantan_df$AKK) + 1.5)) +
labs(
title = "Angka Kematian Kasar (AKK) di Pulau Kalimantan",
subtitle = "Hasil SUPAS",
x = "Provinsi",
y = "Angka Kematian Kasar (per 1.000 Penduduk)"
) +
theme_minimal(base_size = 10) +
theme(
plot.title = element_text(face = "bold", size = 14),
panel.grid.major.x = element_blank()
)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
