Hi,
Continuous variables are divided and frequencies counted in different interval, histograms are drawn, and probability density curves are fitted.
The horizontal coordinates are of the form of different intervals [a,b). Now it seems that the graph I made has problems with both the horizontal coordinates ( no scale lines)and vertical coordinates.
You could also use other data to show your opinion.
Thank you for your help in advance.
set.seed(123)
data <- rnorm(1000, mean = 50, sd = 10)
# 将x分为5个区间
cuts <- cut(data, breaks = c(0, 20, 40, 60, 80, 100), right = FALSE)
# 计算各个区间的频次
freqs <- table(cuts)
# 绘制直方图和概率密度曲线
barplot(freqs, names = c("[0,20)", "[20,40)", "[40,60)", "[60,80)", "[80,100)"))
lines(data, col = "red")
Created on 2023-04-09 with reprex v2.0.2