以下绘图以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. Webkit内核探究【1】——Webkit简介

    出处:http://www.cnblogs.com/jyli/archive/2010/01/31/1660355.html作者:李嘉昱 研究Webkit内核已经有一段时间了,在这期间我花了很多时间去 ...

  2. MVC學習網站

    http://www.cnblogs.com/haogj/archive/2011/11/23/2246032.html

  3. golang interface的使用和实现(翻译整理)

    https://blog.csdn.net/u011409801/article/details/79291221

  4. Go中error类型的nil值和nil

    https://my.oschina.net/chai2010/blog/117923

  5. Track and Follow an Object----4

    原创博文:转载请标明出处(周学伟):http://www.cnblogs.com/zxouxuewei/tag/ ntroduction: 在本示例中,我们将探索包含Kinect摄像头的自主行为. 这 ...

  6. ios利用Reachability确认网络环境3G/WIFI(转)

    iPhone开发技巧之网络篇(4)--- 确认网络环境  开发Web等网络应用程序的时候,需要确认网络环境,连接情况等信息.如果没有处理它们,是不会通过Apple的审查的. Apple 的 例程 Re ...

  7. PHP缓存机制详解

    一,PHP缓存机制详解 我们可以使用PHP自带的缓存机制来完成页面静态化,但是仅靠PHP自身的缓存机制并不能完美的解决页面静态化,往往需要和其他静态化技术(通常是伪静态技术)结合使用. output ...

  8. Cordova 问题点备忘

    1 cordova File插件问题 cordova 5.0创建本地文件夹 目录变成了 file:///data/user/0/com.xxx.xxx/xxx 4.0 是 file:///storag ...

  9. matlab矩阵内存预分配

    matlab矩阵内存预分配就意味着,划定一个固定的内存块,各数据可直接按"行.列指数"存放到对应的元素中.若矩阵中不预配置内存.则随着"行.列指数"的变大.MA ...

  10. grid布局合并单元格

    参考:http://www.w3cplus.com/css3/css-grid-layout-merge-cells.html <!DOCTYPE html> <html lang= ...