0

Consider the data:

foo <- data.frame("Factor" = rep(c("A", "B", "C"), 50),
              "Value" = rbinom(150, 1, .5))

 ggplot(foo, aes(Factor, Value))+
   geom_bar(stat = "summary", fun.y = mean, position = "dodge")

That creates (approximately) this plot:

plot1

I'm trying to limit the y-axis of the plot to a bound that is lower than the natural data (i.e., 0 - .75), but doesn't obscure any aggregated value actually shown in the outputted plot. When doing so with scale_y_continuous(limits = c(0, .99)), the bars dissapear. Trying to figure out how to limit the y-axis without this happening. Your help is much appreciated!

Connor
  • 39
  • 5
  • Try with `scale_y_continuous(limits = c(0, 2))` or ` scale_y_continuous(limits = c(0, 1))` and you will see data. Anything less than `1` is filtering value `1` from the data and there is nothing to show. – MKR Jan 29 '18 at 19:15
  • Even though you have used `fun.y = mean` in `geom_bar` still data filter happens before applying `mean` – MKR Jan 29 '18 at 19:17
  • @MrFlick This question doesnt seem be duplicate. As OP has used `fun.y = mean` which is causing data to get filtered out before limit is applied. Please have a look. May be I'm wrong. – MKR Jan 29 '18 at 19:27

0 Answers0