title: Plot of a Binomial Distribution for various probabilities of success in R
body: <p>Is it possible to plot histogram-like bars/lines for a Binomial distributed random variable with different success probabilities next to each other in R?</p>
  
  <p>The number of trials (n) and the sample space stays the same. Only the probability of success (p) is different. How has the R code to look like in order to have the bars next to each other?</p>
  
  <p>Here is a small example what I mean:</p>
  
  <pre><code>yval &lt;- 0:10 # sample space
  plot(dbinom(yval, 10, 0.5) ~ yval, type = "h", col = "black", ylim = c(0, 0.35))
  lines(dbinom(yval, 10, 1/6) ~ yval, type = "h", col = "red")
  lines(dbinom(yval, 10, 0.6) ~ yval, type = "h", col = "green")
  legend("topright", legend = c("p = 0.5", "p = 1/6", "p = 0.6"),
  col = c("black", "red", "green"), lty = 1, cex = 0.7)
  </code></pre>
  
  <p>With this code the lines are plotted onto each other. What do I have to change here?</p>
  
  <p>Thank you in advance.</p>