R科研作图学习小组

http://group.keyangou.com/RGraph
组长: 管理员:
  • 访问次数:19738
  • 小组等级:9
  • 话题:593
  • 回答:39
  • 签到:393
  • 小组排名:
  • R2-16-第十期作业-综合案例

    fjh19881216 发布于:2018.01.08

    >install.packages("gcookbook")

    > library(gcookbook)

    > library(ggplot2)

    > supp1=c("OJ","OJ","OJ","VC","VC","VC")

    > dose1=c(0.5,1.0,2.0,0.5,1.0,2.0)

    > length1=c(13.23,22.70,26.06,7.98,16.77,26.14)

    > fjh=data.frame(supp1,dose1,length1)

    ggplot(fjh, aes(x=dose1, y=length1, color=supp1,shape=supp1)) +geom_line(position=position_dodge(0.2)) +geom_point(position=position_dodge(0.2),size=4)

    > ggplot(fjh, aes(x=dose1, y=length1, color=supp1,shape=supp1)) +geom_line(position=position_dodge(0.2)) +geom_point(position=position_dodge(0.2),size=4)+theme_bw()+ggtitle("R2-16")

    第一题2.png

    > library(ggplot2)

    > attach(midwest)

    > class(midwest)

    > midwest

    >ggplot(midwest,aes(x = area, y =poptotal,colour = state))+geom_point()+geom_point(aes(col=state,size=popdensity))+geom_smooth(method="loess",se=F)+labs(subtitle="Area Vs Population",y="Population",x="Area",title="R2-16",caption="source:midwest")+xlim(c(0,0.1))+ylim(c(0,500000))

    第二题.png

    > library(ggplot2)

    > library(reshape2)

    >  library(plyr)

    > library(scales)

    > data<- read.csv(file.choose())

    > data

    > mydata<- melt(data,id.vars=c("Name"))

    >  mydata2<-ddply(mydata,.(variable), transform,label=rescale(value))

    >  ggplot(mydata2, aes(x=variable,y=Name))+geom_tile(aes(fill=label))+scale_fill_gradient(low = "blue", high = "green")+xlab("Groups")+ ggtitle("R2-16")

    第三题2.png


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

    小组告示

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