我绘制以下内容:
library(ggplot2)
carrots <- data.frame(length = rnorm(500000, 10000, 10000))
cukes <- data.frame(length = rnorm(50000, 10000, 20000))
carrots$veg <- 'carrot'
cukes$veg <- 'cuke'
vegLengths <- rbind(carrots, cukes)
ggplot(vegLengths, aes(length, fill = veg)) +
geom_density(alpha = 0.2)
现在说我只是想绘制之间的区域x=-5000
来5000
,而不是整个范围。
我怎样才能做到这一点?
library(scales); ... + scale_x_continuous(limits = c(-5000, 5000), oob=squish)
(默认为oob=censor
);看?squish
,?censor
:groups.google.com/forum/#!topic/ggplot2/AsJ6xpmR9tU