以下绘图以Weibull分布(韦伯分布、威布尔分布)为例

关于Weibull分布(韦伯分布、威布尔分布),请参考本人博客http://www.cnblogs.com/wwxbi/p/6141501.html

library(ggplot2)
# 这里的d和y都有大小顺序
d<- seq(0, 5, length.out=10000)
y<-dweibull(d, shape=5, scale=1, log = FALSE)
df<-data.frame(x=d,y)
ggplot(df,aes(x=d,y))+
geom_line(colour="green")+
ggtitle("Weibull distribution \n 概率密度图")

# 这里的h没有大小顺序
h <- rweibull(100000, shape=5, scale=1)
ggplot(NULL,aes(x=h))+
geom_histogram(binwidth = 0.01,fill="white",colour="red")+
ggtitle("Weibull distribution \n 直方图")

ggplot(NULL,aes(x=h))+
geom_density(colour="green")+
ggtitle("Weibull distribution \n 概率密度图") ggplot(NULL,aes(x=h))+
geom_line(stat="density",colour="green")+
ggtitle("Weibull distribution \n 概率密度图")

library(sqldf)
library(ggplot2) d<- seq(0, 5, length.out=10000)
df1<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=0.5",rw=dweibull(d, scale=1,shape=0.5 ))
df2<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=1",rw=dweibull(d, scale=1,shape=1 ))
df3<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=1.5",rw=dweibull(d, scale=1,shape=1.5 ))
df4<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=5",rw=dweibull(d, scale=1,shape=5 )) df5<-sqldf("
select num,groupID,rw from df1
union all
select num,groupID,rw from df2
union all
select num,groupID,rw from df3
union all
select num,groupID,rw from df4 ") df<-subset(df5, rw <2 ) ggplot(df,aes(x=num,y=rw,group=factor(groupID),colour=factor(groupID)))+
geom_line()+
ggtitle("Weibull distribution \n 概率密度图")

  

library(sqldf)
library(ggplot2)
df2<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=1",rw=rweibull(10000, scale=1,shape=1 ))
df3<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=1.5",rw=rweibull(10000, scale=1,shape=1.5 ))
df4<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=5",rw=rweibull(10000, scale=1,shape=5 )) df<-sqldf("
select num,groupID,rw from df2
union all
select num,groupID,rw from df3
union all
select num,groupID,rw from df4 ") ggplot(df,aes(x=rw,group=factor(groupID),colour=factor(groupID)))+
geom_density()+
ggtitle("Weibull distribution \n 概率密度图")

library(sqldf)
library(ggplot2) d<- seq(0, 5, length.out=10000)
df1<-data.frame(num=seq(0,5,length=10000),groupID="λ=0.5,k=1",rw=dweibull(d, scale=0.5,shape=1 ))
df2<-data.frame(num=seq(0,5,length=10000),groupID="λ=1,k=1",rw=dweibull(d, scale=1,shape=1 ))
df3<-data.frame(num=seq(0,5,length=10000),groupID="λ=1.5,k=1",rw=dweibull(d, scale=1.5,shape=1 ))
df4<-data.frame(num=seq(0,5,length=10000),groupID="λ=3,k=1",rw=dweibull(d, scale=3,shape=1 )) df5<-sqldf("
select num,groupID,rw from df1
union all
select num,groupID,rw from df2
union all
select num,groupID,rw from df3
union all
select num,groupID,rw from df4 ") df<-df5 ggplot(df,aes(x=num,y=rw,group=factor(groupID),colour=factor(groupID)))+
geom_line()+
ggtitle("Weibull distribution \n 概率密度图")

ggplot2绘制概率密度图的更多相关文章

  1. ggplot2绘制多图

    参考链接:http://www.cnblogs.com/nxld/p/6065237.html ggplot2.multiplot是一个易于使用的功能,将多个图形在同一页面上使用R统计软件和GGPLO ...

  2. R绘图 第六篇:绘制线图(ggplot2)

    线图是由折线构成的图形,线图是把散点从左向右用直线连接起来而构成的图形,在以时间序列为x轴的线图中,可以看到数据增长的趋势. geom_line(mapping = NULL, data = NULL ...

  3. R-forestplot包| HR结果绘制森林图

    本文首发于“生信补给站”微信公众号,https://mp.weixin.qq.com/s/2W1W-8JKTM4S4nml3VF51w 更多关于R语言,ggplot2绘图,生信分析的内容,敬请关注小号 ...

  4. R绘制韦恩图 | Venn图

    解决方案有好几种: 网页版,无脑绘图,就是麻烦,没有写代码方便 极简版,gplots::venn 文艺版,venneuler,不好安装rJava,参见Y叔 酷炫版,VennDiagram 特别注意: ...

  5. 用canvas绘制折线图

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. php中用GD绘制折线图

    php中用GD绘制折线图,代码如下: Class Chart{ private $image; // 定义图像 private $title; // 定义标题 private $ydata; // 定 ...

  7. 使用Canvas绘制背景图

    原文  http://www.imququ.com/post/use-canvas-as-background-image.html 最近iCloud Web的Beta版换了UI,整体风格变得和iOS ...

  8. Excel应该这么玩——7、我是预言家:绘制趋势图

    让我们先看一个场景:你是公司销售部的员工,你手里有公司最近几年的销售额相关的数据,经理希望你预测下个月的销售额.盯着一堆数据,你或许会想到画一张XY坐标图,然后将每个月份的销售额标定为一个坐标.但是下 ...

  9. 使用Excel 2007绘制甘特图

    本文将教大家如何使用Excel 2007制作甘特图.Excel并未提供甘特图类型,但还是可以绘制甘特图的,方法就是通过对堆积条形图类型进行自定义,使之显示任务.任务工期和层次结构. 下面的过程可帮助创 ...

随机推荐

  1. geoserver 地图性能和缓存

    1.什么是GeoWebCache GeoWebCache是地图缓存软件公司成员开发的一个基于java的开源项目.和其他的缓存系统相似,它作为一个客户端和地图服务的代理.它可以单独部署,适用于任何基于W ...

  2. Bootstrap——导航居中

    这是采用了栅格,设置缩进,使看起来居中,但是手机浏览会靠到最左边.另外center-block类好像也不管用. <div class="row"> <ul cla ...

  3. window apache 多站点配置

    1. 让Apache在启动时能加载虚拟主机模块. 打开Apache安装目录下conf/httpd.conf文件,找到下面两行文字,把最前面的 # 号去掉,然后保存. #LoadModule vhost ...

  4. [RN] 01 - Init: Try a little bit of React Native

    Ref: React Native跨平台移动应用开发 后记:这本书博客味有点浓. 本篇涉及新建工程的若干套路,以及一点语法知识. 创建新工程 (1) 解决的一大核心问题: (2) 使用Javascri ...

  5. Git------解决右键不显示Git Bash Here问题

    步骤: 1.通过在“运行”中输入‘regedit’,打开注册表. 2.找到[HKEY_CLASSES_ROOT\Directory\Background]. 3.在[shell]下右键-新建项[ope ...

  6. PHP 源码加密模块 php-beast

    PHP Beast是一个源码加密模块,使用这个模块可以把PHP源码加密并在此模块下运行. 为什么要用PHP-Beast? 有时候我们的代码会放到代理商上, 所以很有可能代码被盗取, 或者我们写了一个商 ...

  7. Python对象(上)

    Python是一门面向对象的语言,在Python中一切都是对象,函数是对象,类型也是对象. 下面就看看Python中对象相关的内容. Python对象基本概念 Python对象有三个基本的要素: 身份 ...

  8. ios开发之--tableview刷新某一个区和某一行

    在开发中,有时候,我们不需要刷新整个表,只需要刷新局部数据即可,具体代码如下: //section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWith ...

  9. mysql 行转列 (case when的使用)

    现有 table1 如下 table2 如下 需要统计:各个部门每个月的绩效总和 实现如下:

  10. apt-get/dpkg常用指令备查

    apt-get install <package> Downloads <package> and all of its dependencies, and installs ...