R语言画柱状图

# First, take a look at the BOD data
BOD
#> Time demand
#> 1 1 8.3
#> 2 2 10.3
#> 3 3 19.0
#> 4 4 16.0
#> 5 5 15.6
#> 6 7 19.8
par(las = 1) # 纵坐标横排显示
barplot(
height = BOD$demand, # x轴对应每个柱子的高度数据(BOD 表中 demand 列)
names.arg = BOD$Time # 指定每根柱子对应的标签(x轴刻度文字)
)
library(ggplot2)
ggplot(BOD, aes(x = factor(Time), y = demand)) +
geom_col()

评论

发表评论

了解 数据控|突破是我们的每一步 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读