-
绘图前请思考:
查看全部 -
拷贝图形:
查看全部 -
生成图形的两种途径:
查看全部 -
R支持的图形设备:
查看全部 -
pal<-colorRamp(c("red","blue")) pal(0) pal(1) pal(0.5) pal(seq(0,1,len=10)) pal<-colorRampPalette(c("red","blue")) pal(0) pal(1) pal(0.5) pal(10) brewer.pal.info cols<-brewer.pal(3,"Greens") cols pal<-colorRampPalette(cols) pal image(volcano,col = pal(20)) display.brewer.pal(3,"Greens")
查看全部 -
R语言绘图之颜色:
RcolorBrewer包
查看全部 -
R语言绘图之颜色:
grDevice包
查看全部 -
library(ggplot2) ggplot(airquality, aes(Wind, Temp))+ geom_point(aes(color = factor(Month), group = 1,alpha = 0.4, size = 5))+ geom_smooth(method = "lm", se = F, aes(group = 1))#前一个group只输出群体拟合,后一个控制再做一条群体拟合 ggplot(airquality, aes(Wind, Temp)) + geom_point()+ geom_smooth(method = "lm", se = F, aes(group = 1)) ggplot(airquality, aes(Wind, Temp, col = factor(Month))) + geom_point()+ geom_smooth(method = "lm", se = F, aes(group = 1))+ scale_color_manual("Month", values = myColors)+ facet_grid(.~Month)+ theme_classic()
查看全部 -
library(ggplot2) qplot(Wind, Temp, data = airquality, col = Month, shape = Month, size = Month, xlab = "Wind(mph)", ylab = "Temperature", main = "Wind vs.Temperature" ) qplot(Wind, Temp, data = airquality, geom = c("point", "smooth")) qplot(Wind, Temp, data = airquality, facets = Month~.) qplot(Wind, Temp, data = airquality, facets = .~Month) qplot(Wind, data = airquality, facets = .~Month) qplot(Wind, data = airquality, fill = Month) qplot(Wind, data = airquality, geom = "dotplot")
查看全部 -
绘图函数:
查看全部 -
层的概念:将不同的层拼接起来就构成了图
查看全部 -
#Lattice绘图系统
install.packages("lattice")
library(lattice)
xyplot(Temp~Ozone,data=airquality)
airquality$Month <-factor(airquality$Month) #将Month从数值变量转换为分类变量
xyplot(Temp~Ozone|Month,data=airquality,layout=c(5,1))
q <- xyplot(Temp~Wind,data=airquality)
print(q)
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(2,1))
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") })
查看全部 -
lattice和Base的重要区别
#Base绘图函数直接在图形设备上绘图
#Lattice绘图函数返回trellis类对象
# 打印函数真正执行了在设备上绘图
# 命令执行时, trellis类对象会被自动打印.
查看全部 -
Lattice绘图系统 :
#xyplot/bwplot/histgram/stripplot/dotplot/splom/levelplot/contourplot
#格式:xyplot(y ~ x|f * g, data)
#panel,用来控制每个面板内的绘图
查看全部 -
#全局参数
par("bg")#背景颜色
par("col")#颜色
par("mar")#(bottom,left,right, right)
par("mfrow")
par("mfcol")
par(mfrow = c(1,2)) #一行两列,先填充行
查看全部
举报