Hi:
On Tue, May 8, 2012 at 2:31 PM, Zack Weinberg <
za...@panix.com> wrote:
> This example is a little silly, but it does illustrate the situation:
>
> library(ggplot2)
> library(reshape)
>
> d <- melt(data.frame(A = rnorm(n=100, mean=0, sd=1),
> B = rnorm(n=4000, mean=10, sd=40)),
> id.vars=c())
>
> ggplot(d, aes(x=value)) + geom_density() +
> facet_wrap(~variable, scales='free_x')
>
> # I want to set the x-axis limits to (-4,4) for facet A and (-100,
> 100) for facet B,
> # and possibly also set manual x-axis breaks independently for each facet
In that case I think you'll have to create separate plots and then
paste them together using the gridExtra package, something like
e <- data.frame(A = rnorm(n=100, mean=0, sd=1),
B = rnorm(n=4000, mean=10, sd=40))
a <- ggplot(e, aes(x = A)) + geom_density() + xlim(-4, 4)
# The upper ylim is chosen to approximate equal y-axis
# ticks in the two plots
b <- ggplot(e, aes(x = B)) + geom_density() +
xlim(-100, 100) + ylim(0, 0.47)
library('gridExtra')
grid.arrange(a, b, nrow = 1)
AFAIK, faceting doesn't give you the level of control over individual
panels that you desire.
Dennis