Re: Combine coord_fixed() and coord_flip()?

1,145 views
Skip to first unread message
Message has been deleted

Dennis Murphy

unread,
May 21, 2013, 11:57:31 AM5/21/13
to Ben Harrison, ggplot2
You can only use one coord_*() function on a given ggplot since it
changes the coordinate system after everything else has been done. To
change the aspect ratio, you can use the corresponding argument in the
theming system:

... + coord_flip() + theme(aspect.ratio = 1)

Untested in the absence of a reproducible example. If this doesn't
work, please provide one.

Dennis

On Mon, May 20, 2013 at 10:38 PM, Ben Harrison
<ben.ha...@liquidmesh.com> wrote:
> I am trying to change the aspect ratio of a particular plot, and the only
> way I've worked out to do this is with coord_fixed(). If there are other
> ways, then this question might be redundant!
>
> The plot describes the changes in a variable (GR) with depth.
> Depth being independent, I place it in x, but as per custom, we plot depth
> on vertical axis.
> I also need depth to be increasing from top to bottom:
>
> ggplot(data=logs, aes(x=DEPTH, y=GR)) + geom_line() +
> scale_x_reverse() + coord_flip()
>
> This is fine, but the aspect ratio is unfettered.
>
> last_plot() + coord_fixed(ratio=1)
>
> Has the desired effect, but resets the flip, so that depth is again on the
> horizontal axis. Is there a way to combine the two? I haven't been able to
> figure it out.
>
> --
> --
> 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 ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ben Harrison

unread,
May 21, 2013, 6:51:44 PM5/21/13
to ggp...@googlegroups.com, Ben Harrison
Thank you Dennis, that does work.

The docs at http://docs.ggplot2.org/current/theme.html do not mention this at all.


Ben.
Reply all
Reply to author
Forward
0 new messages