Thư viên ggplot2

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
data=data.frame(value=rnorm(100))
p <- ggplot(data, aes(x=value)) + 
  geom_histogram()
p
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Chọn số khoảng (bins). Số khoảng thường lấy xấp xỉ bằng căn bậc 2 của cỡ mẫu

p <- ggplot(data, aes(x=value)) + 
  geom_histogram(bins=10)
p

Tô màu viền

p <- ggplot(data, aes(x=value)) + 
  geom_histogram(bins=10,color="white")
p

Tô màu biểu đồ

p <- ggplot(data, aes(x=value)) + 
  geom_histogram(bins=10,color="white", fill="blue")
p

Đổi tên nhãn

p <- ggplot(data, aes(x=value)) + 
  geom_histogram(bins=10,color="white", fill="blue")+
  labs(x="Biểu đồ histogram")
p