服务热线
178 0020 3020
#1
library(ggplot2)
tg <- ToothGrowth
tgc=summarySE(tg,measurevar="len", groupvars=c("supp","dose"))
pd =position_dodge(0.1)
p=ggplot(tgc, aes(x=dose, y=len, colour=supp, group=supp))+geom_line(position=pd)
mytheme=theme_bw()+theme(panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),legend.position = c(1,0),legend.justification = c(1,0),legend.key=element_blank(),legend.background = element_blank())
p+geom_errorbar(aes(ymin=len-se, ymax=len+se), colour="black", width=.1, position=pd)+geom_point(position=pd,size=3, shape=21, fill="white")+xlab("Dose (mg)") + ylab("Tooth length") +scale_color_brewer(palette="Dark2") +labs(color="Supplement type")+scale_color_discrete(labels=c("Orange juice", "Ascorbic acid"))+ggtitle("R2-21\nThe Effect of Vitamin C onTooth Growth in Guinea Pigs")+mytheme
#2
options(scipen = 999)
theme_set(theme_bw())
data("midwest",package="ggplot2")
gg=ggplot(midwest,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))
gg+geom_smooth(method="loess",se=F,col="red")+xlim(c(0,0.1))+ylim(c(0,500000))+scale_color_brewer(palette = "Accent")+ggtitle("R2-21")+xlab("Area")+ylab("Population")
#3
mydata=read.csv(file.choose())
mymatrix=data.matrix(mydata[,c(-1)])
row.names(mymatrix)=mydata[,1]
heatmap(mymatrix,Rowv=NA,Colv=NA,scale="column")
附件