R科研作图学习小组

http://group.keyangou.com/RGraph
组长: 管理员:
  • 访问次数:28540
  • 小组等级:9
  • 话题:593
  • 回答:39
  • 签到:439
  • 小组排名:
  • R2-33 综合任务

    R48-小之 发布于:2018.01.09

    Task1

    library(ggplot2)

    data<- ToothGrowth

    write.table (data, file ="data.csv", sep =",", row.names =FALSE, col.names =TRUE, quote =TRUE)

    data1<-read.csv("R2-10.csv")

    p<-ggplot(data1,aes(data1,x=dose,y=len,color=supp))+geom_line(size=1.5,position=pd)+geom_point(size=3,position=pd)+

    geom_errorbar(aes(ymin=len-sd,ymax=len+sd,color=supp),size=1.2,position=pd)+ggtitle("R2-33")+xlab("Dose(mg)")+ylab("Tooth length")+

    scale_color_hue(name="Supplement type",breaks=c("OJ","VC"),labels=c("Orange juice","Ascorbic acid"))+

    theme_bw()+theme(legend.justification=c(1,0),legend.position=c(1,0))

    P

     1.png

    Task2

    library(ggplot2)

    data2<-midwest

    head(data2)

    p<- ggplot(data2,aes(x=area,y=poptotal))+geom_point(aes(col=state,size=popdensity))+

    geom_smooth(method="loess",se=F)+xlim(c(0,0.1))+ylim(c(0,500000))+xlab("Area")+ylab("Population")+labs(subtitle="Area vs Population",title="R2-33",caption="Source:midwest")

    p+theme_bw()


    2.png

    Task3

    install.packages("RColorBrewer")

    library(RColorBrewer)

    library(ggplot2)

    data3<- read.csv("Task3.csv")

    mymatrix=data.matrix(data3[,c(-1)])

    row.names(mymatrix)=data3[,1]

    heatmap(mymatrix,Rowv=NA,Colv=NA,col=brewer.pal(9,"Blues"),scale="column",main="R2-33")

     

     3.png

     

     


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

    小组告示

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