R科研作图学习小组

http://group.keyangou.com/RGraph
组长: 管理员:
  • 访问次数:18355
  • 小组等级:9
  • 话题:588
  • 回答:39
  • 签到:385
  • 小组排名:
  • R2-29 第十次作业 综合作业

    CISO 发布于:2018.01.10

    # Figure 1


    library(ggplot2)

    library(Rmisc)

    dat <- ToothGrowth

    dat2 = summarySE(dat,measurevar="len", groupvars=c("supp","dose"))

    pd = position_dodge(0.1)

    p=ggplot(dat2, aes(x=dose, y=len, colour=supp, group=supp))+geom_line(position=pd)

    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")+labs(color="Supplement type")+ggtitle("R2-29 CC")


    # Figure 2


    options(scipen = 999)

    data("midwest",package="ggplot2")

    p=ggplot(midwest,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+geom_smooth(method="loess",se=T,col="red")+xlim(c(0,0.1))+ylim(c(0,500000))+xlab("Area")+ylab("Population")

    p+ggtitle("R2-29 CC")


    # Figure 3


    library(reshape2)

    library(plyr)

    library(scales)

    dat<- read.csv(file.choose())

    dat2 <- melt(dat, id.vars=c("Name"))

    dat2 <- ddply(dat2, .(variable), transform, label = rescale(value))

    ggplot(dat2, aes(x=variable,y=Name)) + geom_tile(aes(fill=label))+scale_fill_gradient(low="yellow",high ="blue")+xlab("Type")+ ggtitle("R2-29 CC")

                                                  

    10-1.png

    10-2.png

    10-3.png

     
    0条评论 100浏览 邀请回答
    沙发空缺中~

    小组告示

    科研狗 2012-2016 京ICP备16006621 科研好助手,专业的科研社交共享平台