R2-26-第二期-ggplot2画直方

郑磊 2017-11-15 00:04:32 阅读: 967

R2_1 <- read.table(file ="data/R2-2.1.csv", sep = ",", header = TRUE)

library(ggplot2)

ggplot(R2_1,aes(x=bwt,fill=factor(R2_1$smoke)))+

  geom_histogram(binwidth=400,position="dodge",color="black")+

  ggtitle("R2-26")+xlab("birthweight")+

  scale_fill_discrete(h=c(0,200),c=400,name="Smoke",labels=c("No","Yes"))+

  theme(panel.grid.major = element_blank(),

        panel.grid.minor = element_blank(),

        panel.border = element_blank(),

        panel.background = element_rect(fill="white"),

        axis.line = element_line(colour="black"))

Rplot01.png


data(diamonds)

library(ggplot2)

ggplot(diamonds,aes(x=carat,color=color))+

  geom_line(stat="density")+

  ggtitle("R2-26")+xlab("price")+

  theme(panel.grid.major = element_blank(),

        panel.grid.minor = element_blank(),

        panel.border = element_blank(),

        panel.background = element_rect(fill="white"),

        axis.line = element_line(colour="black"))

Rplot02.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

微信服务号