1

Let's consider 3 extreme distributions. Two of them has a very long tail, while the last one is clearly bimodal.

require(poweRlaw)
m = displ$new()
m$setXmin(10);m$setPars(5)
f1 = function(n) {dist_rand(m, n)}
set.seed(2)
n = 200
A = data.frame(x = rep(c(1,2,3), each=n), y = c(f(2*n), f(3*n/4), rnorm(n/4, mean=5000, sd=10)))
ggplot(A, aes(y=y, x=factor(x))) + geom_boxplot()

enter image description here

The long tail make the observation of the difference between the mean hard to tell. So, I wanted to zoom in

ggplot(A, aes(y=y, x=factor(x))) + geom_boxplot() + 
scale_y_continuous(limits=c(c(0, 100)))

enter image description here

but the problem is when I zoom in, data that are now outside the plotting frame are not taking into account for creating the boxplot. How can I solve this issue?

Andrew
  • 9,090
  • 8
  • 46
  • 59
Remi.b
  • 17,389
  • 28
  • 87
  • 168
  • 2
    While I'm looking for a good duplicate, the solution is to use `coord_cartesian`. – joran Feb 25 '15 at 17:04
  • 1
    https://stackoverflow.com/questions/7892764/stop-ggplot2-from-dropping-data-points-outside-of-axis-limits/7892925#7892925 – Andrew Feb 25 '15 at 17:06
  • Awesome! I am waiting for the link to the duplicate! Thanks a lot joran. – Remi.b Feb 25 '15 at 17:07

0 Answers0