-
qplot()、ggplot()查看全部
-
ggplot2绘图系统查看全部
-
设置种子 set.seed()查看全部
-
Lattice与Base的区别查看全部
-
Lattice绘图系统查看全部
-
par(mfrow=c(1,2)) 两个图表一行两列查看全部
-
绘图 回归线 abline查看全部
-
hist(airquality$Wind) boxplot(airquality$Wind) boxplot(Wind~Month,airquality,xlab="Month",ylab="Speed(mph)") plot(airquality$Wind,airquality$Temp) with(airquality,plot(Wind,Temp)) with(airquality,plot(Wind,Temp, main = "Wind and Temp in NYC", type = "n")) #9月份的数据点为红色 with(subset(airquality,Month==9), points(Wind,Temp,col="red")) #5月份的数据点为蓝色 with(subset(airquality,Month==5), points(Wind,Temp,col="blue")) #6、7、8三个月为黑点 with(subset(airquality,Month %in% c(6,7,8)), points(Wind,Temp,col="black")) #拟合回归线 fit <- lm(Temp ~ Wind,airquality) abline(fit,lwd=2) #添加图示 legend("topright",pch=1, col=c("red","blue","black"), legend = c("Sep","May","Other"))查看全部
-
分类变量的特征和可视化 1. 一个分类变量的可视化 —频率表(frequency table)、条形图(bar plot) 2. 两个分类变量的关系 —关联表(continggency table)、相对频率表(relative frequencies) —分段条形图、相对频率分段条形图 —马赛克图(mosaicplot) 3. 一个分类变量、一个数值变量的关系 ——并排箱图(side-by-side box plot)查看全部
-
小结查看全部
-
library(ggplot2) qplot(Wind,Temp,data=airquality,color=Month, facets = Month~., geom = c("point","smooth")) qplot(Wind,data=airquality,fill=Month) qplot(Wind,data=airquality,geom="density") qplot(Wind,data=airquality,size=I(5),geom="dotplot")查看全部
-
fill 数据用不同颜色来表示 density 轮廓查看全部
-
color 颜色 size 大小 shape 形状 放到 I 函数中查看全部
-
ggplot2层查看全部
-
library(lattice) xyplot(Temp~Ozone,data=airquality) airquality$Month <- factor(airquality$Month) q <- xyplot(Temp~Ozone | Month,data=airquality, layout=c(5,1)) #使用随机数 就要使用种子点 set.seed(1) x <- rnorm(100) f <- rep(0:1, each=50) y <- x + f - f*x + rnorm(100,sd=0.5) f <- factor(f,labels = c("Group1","Group2")) xyplot(y~x|f,layout=c(1,2)) xyplot(y~x | f, panel = function(x,y){ panel.xyplot(x,y) panel.abline(v=mean(x),h=mean(y),lty=2) panel.lmline(x,y,col="red") })查看全部
举报
0/150
提交
取消