R2-38 综合作业

jinhui 2018-01-09 23:36:52 阅读: 1025

#Figure 1

setwd("D:/projects/R learning/week 10 data")

data<-read.csv("R2-1-2.csv",header=TRUE)

library(ggplot2)

graph <- ggplot(data=data, aes(Time,value,color =SIZE,shape = SIZE))+

  geom_line(color = "black")+geom_point(size=4)+ 

  ggtitle("R2-38")+theme_bw()+theme(panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank())


#Figure 2

library(ggplot2)

options(scipen=999)

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

ggplot(midwest, aes(x=area, y=poptotal)) + 

  geom_point(aes(col=state, size=popdensity)) + 

  geom_smooth(method="loess", se=T) +

  scale_color_brewer(palette = "Spectral")+ 

  xlim(c(0, 0.1)) + 

  ylim(c(0, 500000)) + 

  labs(subtitle="Area Vs Population", 

       y="Population", x="Area",title="R2-38",caption = "Source: midwest")


#Figure 3

library(reshape2)

library(ggplot2)

library(plyr)

library(scales)

data_heatmap<- read.csv("task3.csv")

data_m <- melt(data_heatmap, id.vars=c("Name"))

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

ggplot(data_m, aes(x=variable,y=Name)) + 

  geom_tile(aes(fill=label)) + 

  scale_fill_gradient(low = "white", high = "steelblue") +

  xlab("Type") + theme_bw() + ggtitle("R2-38")


1.png


2.png

3.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号