Skip to content

ggplot aspect ratio

2 messages · Ross Boylan, Hadley Wickham

#
Is there a way to control the aspect ratio of plots using ggplot?
Specifically, I'm using the formula=a~b argument to produce a grid of
plots, but the overall width of the result seems to vary for reasons
that are obscure to me.

This affects not only the appearance of the plots but the amount of
space available for the title (which seems to be right justified
relative to the right edge of the grid).

I've tried tweaking some parameters in the past, but they had no effect
that I could tell.

Perhaps related to that, my previous attempts to use abline to produce a
45 degree angle always produced a flat straight line.

There are also a bunch of other tweaks I want to make to get output
presentation ready.  Is it time to try ggplot2?  I found I could get
results very quickly with ggplot, but am not sure how much control it
gives me over the finer details.

Thanks.
#
Hi Ross,

In brief, you can use ggopt(aspect.ratio = 1) or p$aspect.ratio <- 1
to set the aspect ratio for all plots, or for a single plot
respectively.  There are a few example of this at
http://had.co.nz/ggplot2/coord_equal.html

I am also preparing a chapter for the ggplot book which will discuss
this, as well as more general details of customising absolutely every
aspect of ggplot2 with grid.  I hope to have this out by the end of
the week - I'll probably send another anouncement to R packages when
this is ready.

You should be able to start using ggplot2 with very little effort,
especially if you have been using qplot a lot.

Hadley
On 6/5/07, Ross Boylan <ross at biostat.ucsf.edu> wrote: