2016-10-29 15 views
1

2つの二項pdfのグラフを別々の方法で作成し、その重なりを影で塗りつぶす方法はありますか?2つの二項分布が重複するR

+0

がhttp://www.cookbook-r.com/Graphs/Plotting_distributions_(ggplot2)/#histogram-andを参照してください。 -density-plots-with-multiple-groups – Bernhard

+0

"二項分布のグラフ"とは何を意味するのでしょうか? http://stackoverflow.com/questions/6957549/overlaying-histograms-with-ggplot2-in-r –

答えて

1

これを試してみてください:

df <- rbind(data.frame(binom=rbinom(1000, 20, 0.2), binomial.p='0.2') , data.frame(binom=rbinom(1000, 20, 0.5),binomial.p='0.5')) 
library(ggplot2) 
ggplot(df, aes(binom, fill=binomial.p)) + 
geom_histogram(position = 'dodge', binwidth = 1) + 
xlab('Number of success (n=20)') 

enter image description here

ggplot(df, aes(binom, fill=binomial.p)) + 
geom_density(alpha=0.2) + 
xlab('Number of success (n=20)') 

enter image description here

関連する問題