1

A sample image that I would like to plot

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

2
  • try facet_wrap( ~ variable, scales = "free_x"). Also provide a reproducible example link Commented Jun 21, 2017 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_() Commented Jun 21, 2017 at 19:14

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.