library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
data <- data.frame(
Jam_Belajar = c(2, 3, 4, 5, 6, 7, 8, 9, 10),
Nilai = c(55, 60, 65, 70, 75, 80, 85, 90, 95)
)
ggplot(data, aes(x = Jam_Belajar, y = Nilai)) +
geom_point(size = 3, color = "steelblue") +
geom_smooth(method = "lm", se = TRUE, color = "darkred") +
labs(
title = "Hubungan Jam Belajar dan Nilai Ujian",
x = "Jam Belajar per Hari",
y = "Nilai Ujian"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data, aes(x = Nilai)) +
geom_histogram(
bins = 5,
fill = "skyblue",
color = "black"
) +
labs(
title = "Distribusi Nilai Ujian Mahasiswa",
x = "Nilai",
y = "Frekuensi"
) +
theme_minimal()

ggplot(data, aes(y = Nilai)) +
geom_boxplot(fill = "lightgreen") +
labs(
title = "Boxplot Nilai Ujian Mahasiswa",
y = "Nilai"
) +
theme_minimal()
