R2-37- 第二期-ggplot2画直方图、密度图

洪学志 2017-11-13 23:01:33 阅读: 1194

mydata <- read.csv("/Users/Hong/Desktop/data/data3/R2-2.1.csv",header=T)

library(ggplot2)

mydata$smoke <- factor(mydata$smoke)

ggplot(mydata,aes(x=bwt,fill=smoke))+geom_histogram(position="dodge",binwidth=400,color="black")+xlab("birth weight")+ggtitle("R2-37")+scale_fill_discrete(labels=c("No","Yes"))

3-1.png

library(ggplot2)

ggplot(diamonds,aes(x=carat,color=color))+geom_line(stat="density")+xlab("price")+ggtitle("R2-37")+theme_bw()

3-2.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-2025 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号