1

A sample image that I would like to plot

I am trying to combine two distributed graphs using ggplot. but unsucessful.

M--
  • 25,431
  • 8
  • 61
  • 93
  • try `facet_wrap( ~ variable, scales = "free_x")`. Also provide a reproducible example [link](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – phaser Jun 21 '17 at 19:08
  • ggplot(X,aes(x=rating, fill = cond)) + geom_density(alpha = .3). When trying this I am getting error like Error: Mapping should be created with aes() or aes_() – Harsh Davey Jun 21 '17 at 19:14

1 Answers1

1

If you have provided a reproducible example it'd be easier but apart from reproducing distributions the code below desires what you want:

ggplot(NULL, aes(as.numeric(BIN))) + 
    geom_bar(aes(fill = "0.2"), data = bin1, alpha = 0.5) +
    geom_bar(aes(fill = "0.8"), data = bin2, alpha = 0.5)

Which will give us:

enter image description here

Data:

  #some fake data
  bin1<-rbinom(1000,100,.2)
  bin2<-rbinom(1000,100,.8)


  bin1 <- data.frame(cbind(bin1,"0.2"))
  bin2 <- data.frame(cbind(bin2,"0.8"))
  colnames(bin1)[1] <- "BIN"
  colnames(bin2)[1] <- "BIN"
  bin1[,1] <- as.numeric(bin1[,1])
  bin2[,1] <- as.numeric(bin2[,1])
  bin <- rbind(bin1,bin2)
  bin <-data.frame(bin)
Community
  • 1
  • 1
M--
  • 25,431
  • 8
  • 61
  • 93