Zack Weinberg | 5 May 01:45 2012
Picon

Manually setting axis limits, breaks, etc. per facet

In 0.9, is it still impossible to manually control the arguments to
scale_x / scale_y under faceting?  If not, how is it done?

Thanks,
zw

Brandon Hurr | 8 May 20:51 2012
Picon

Re: Manually setting axis limits, breaks, etc. per facet

I don't know. I'm happy to try and let you know if you have a working example. 

On Sat, May 5, 2012 at 12:45 AM, Zack Weinberg <zackw-VmQCmMdMyN0AvxtiuMwx3w@public.gmane.org> wrote:
In 0.9, is it still impossible to manually control the arguments to
scale_x / scale_y under faceting?  If not, how is it done?

Thanks,
zw

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2 <at> googlegroups.com
To unsubscribe: email ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
More options: http://groups.google.com/group/ggplot2

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggplot2-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Zack Weinberg | 8 May 23:31 2012
Picon

Re: Manually setting axis limits, breaks, etc. per facet

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

On Tue, May 8, 2012 at 11:51 AM, Brandon Hurr <brandon.hurr@...> wrote:
> I don't know. I'm happy to try and let you know if you have a working
> example.
>
> On Sat, May 5, 2012 at 12:45 AM, Zack Weinberg <zackw@...> wrote:
>>
>> In 0.9, is it still impossible to manually control the arguments to
>> scale_x / scale_y under faceting?  If not, how is it done?
>>
>> Thanks,
>> zw
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing list.
>> Please provide a reproducible example:
>> https://github.com/hadley/devtools/wiki/Reproducibility
>>
>> To post: email ggplot2@...
>> To unsubscribe: email ggplot2+unsubscribe@...
>> More options: http://groups.google.com/group/ggplot2
>
>

--

-- 
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2@...
To unsubscribe: email ggplot2+unsubscribe@...
More options: http://groups.google.com/group/ggplot2

Dennis Murphy | 9 May 01:20 2012
Picon

Re: Manually setting axis limits, breaks, etc. per facet

Hi:

On Tue, May 8, 2012 at 2:31 PM, Zack Weinberg <zackw@...> 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

>
> On Tue, May 8, 2012 at 11:51 AM, Brandon Hurr
<brandon.hurr@...> wrote:
>> I don't know. I'm happy to try and let you know if you have a working
>> example.
>>
>> On Sat, May 5, 2012 at 12:45 AM, Zack Weinberg <zackw@...> wrote:
>>>
>>> In 0.9, is it still impossible to manually control the arguments to
>>> scale_x / scale_y under faceting?  If not, how is it done?
>>>
>>> Thanks,
>>> zw
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
>>> mailing list.
>>> Please provide a reproducible example:
>>> https://github.com/hadley/devtools/wiki/Reproducibility
>>>
>>> To post: email ggplot2@...
>>> To unsubscribe: email ggplot2+unsubscribe@...
>>> More options: http://groups.google.com/group/ggplot2
>>
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggplot2@...
> To unsubscribe: email ggplot2+unsubscribe@...
> More options: http://groups.google.com/group/ggplot2

--

-- 
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2@...
To unsubscribe: email ggplot2+unsubscribe@...
More options: http://groups.google.com/group/ggplot2

Zack Weinberg | 9 May 22:30 2012
Picon

Re: Manually setting axis limits, breaks, etc. per facet

I'll try this with my real dataset and see how it goes.  However,
while haven't used exactly this tactic in the past, I did do something
very similar (involving manual setup of grid viewports) and the plots
came out subtly misaligned, I think because the x-axis labels took up
different amounts of vertical space in each plot.

zw

On Tue, May 8, 2012 at 4:20 PM, Dennis Murphy <djmuser@...> wrote:
> Hi:
>
> On Tue, May 8, 2012 at 2:31 PM, Zack Weinberg <zackw@...> 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
>
>>
>> On Tue, May 8, 2012 at 11:51 AM, Brandon Hurr
<brandon.hurr@...> wrote:
>>> I don't know. I'm happy to try and let you know if you have a working
>>> example.
>>>
>>> On Sat, May 5, 2012 at 12:45 AM, Zack Weinberg <zackw@...> wrote:
>>>>
>>>> In 0.9, is it still impossible to manually control the arguments to
>>>> scale_x / scale_y under faceting?  If not, how is it done?
>>>>
>>>> Thanks,
>>>> zw
>>>>
>>>> --
>>>> You received this message because you are subscribed to the ggplot2
>>>> mailing list.
>>>> Please provide a reproducible example:
>>>> https://github.com/hadley/devtools/wiki/Reproducibility
>>>>
>>>> To post: email ggplot2@...
>>>> To unsubscribe: email ggplot2+unsubscribe@...
>>>> More options: http://groups.google.com/group/ggplot2
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing list.
>> Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
>>
>> To post: email ggplot2@...
>> To unsubscribe: email ggplot2+unsubscribe@...
>> More options: http://groups.google.com/group/ggplot2

--

-- 
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2@...
To unsubscribe: email ggplot2+unsubscribe@...
More options: http://groups.google.com/group/ggplot2


Gmane