![d6347e39e22376d73c5781aa97e7dfff.png](https://i-blog.csdnimg.cn/blog_migrate/dba47280e5bc57ce108db1178d99746d.jpeg)
R语言直方图绘制ggplot2
素娥
2020/10/4
本文我们要用iris数据集进行直方图的绘制
本文主要使用ggplot2包中的ggplot()+geom_histgram()函数进行绘制图片
首先还是观察数据类型
data<-iris
library(knitr)
tt<-head(data,15)
kable(tt)
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
4.6 | 3.4 | 1.4 | 0.3 | setosa |
5.0 | 3.4 | 1.5 | 0.2 | setosa |
4.4 | 2.9 | 1.4 | 0.2 | setosa |
4.9 | 3.1 | 1.5 | 0.1 | setosa |
5.4 | 3.7 | 1.5 | 0.2 | setosa |
4.8 | 3.4 | 1.6 | 0.2 | setosa |
4.8 | 3.0 | 1.4 | 0.1 | setosa |
4.3 | 3.0 | 1.1 | 0.1 | setosa |
5.8 | 4.0 | 1.2 | 0.2 | setosa |
**导入ggplot2包 | ** |