[R] problem with multiple plots (mfrow, mar)
jim at bitwrit.com.au
Fri Feb 19 09:44:34 CET 2010
On 02/19/2010 04:10 AM, Peter Neuhaus wrote:
> Dear R-users,
> I often stack plots that have the same x-axis. To save space and have
> the plots themselves as large as possible I like to minimize the margins
> between the plots to zero. I use the "mfrow" and "mar" parameters to
> achieve this.
> However, the different margin settings for the individual plots lead to
> the inner plots being higher than the two outer plots. To make the
> data in the individual subplots visually comparable, I would like
> to have all plots with a plotting area of exactly the same height.
The two par arguments "fin" and "pin" allow a solution. What you want is
for the second values in "pin" (Plot dimensions in INches) to be the
same for all your plots. You can get an approximation by using the
layout function instead of mfrow and setting the height vector to
correct for the space used in the top and bottom plots. If you are not
doing lots of these plots or you are doing only a few variations, you
can just print out par("pin") after each plot and see how much they
differ and adjust the height vector until all "pin"s are the same. Try
setting the height vector in layout to the "fin"s (Figure dimensions in
INches) that are printed out using the default of all heights equal.
More information about the R-help