Thursday, 14 September 2017

r - Avoid that `scale_y_continuous` take data points away

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?

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...