Discussion:
How to avoid overlapping y axis labels between facets
Etienne B. Racine
2012-12-12 20:11:07 UTC
Permalink
How can I avoid overlapping y-axis labels between facets.

e.g. :
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am)

Generally has overlapping labels on the Y-axis (0.35 meets 0.10). Is there
an easy workaround ?

Thanks,
Etienne
--
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-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Dennis Murphy
2012-12-12 20:29:26 UTC
Permalink
Hi:

This is controlled by the panel.margin theme element:

qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))

Adjust the margin to your requirements.

Dennis
Post by Etienne B. Racine
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am)
Etienne B. Racine
2012-12-12 20:54:30 UTC
Permalink
Thanks Dennis. My only reservation is that I need the full usage of the
plotting area since I have a lot of facets. Would it be possible to play
with the y-axis labeling instead of the margins ?

Etienne
Post by Dennis Murphy
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
Adjust the margin to your requirements.
Dennis
Post by Etienne B. Racine
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am)
--
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-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Dennis Murphy
2012-12-12 22:05:54 UTC
Permalink
Hi:

I can think of several potential options:

* reduce the font size on the axis tick labels (see theme(axis.text.y)
and its size element);
* increase the limits on the y-range;
* modify the position of the breaks for the y-scale (see scale_y_continuous()).

There may well be others that are more appropriate to your actual
problem, but since you apparently haven't provided a reproducible
example that closely resembles your actual problem, this is all
speculation...

Dennis
Post by Etienne B. Racine
Thanks Dennis. My only reservation is that I need the full usage of the
plotting area since I have a lot of facets. Would it be possible to play
with the y-axis labeling instead of the margins ?
Etienne
Post by Dennis Murphy
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
Adjust the margin to your requirements.
Dennis
Post by Etienne B. Racine
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am)
Etienne B. Racine
2012-12-13 15:51:53 UTC
Permalink
Thanks a lot Dennis, I've decided to remove the two external ticks, however
I couldn't find an explicit option for it, so I manually set the breaks.

Etienne
Post by Dennis Murphy
* reduce the font size on the axis tick labels (see theme(axis.text.y)
and its size element);
* increase the limits on the y-range;
* modify the position of the breaks for the y-scale (see
scale_y_continuous()).
There may well be others that are more appropriate to your actual
problem, but since you apparently haven't provided a reproducible
example that closely resembles your actual problem, this is all
speculation...
Dennis
Post by Etienne B. Racine
Thanks Dennis. My only reservation is that I need the full usage of the
plotting area since I have a lot of facets. Would it be possible to play
with the y-axis labeling instead of the margins ?
Etienne
Post by Dennis Murphy
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
Adjust the margin to your requirements.
Dennis
On Wed, Dec 12, 2012 at 12:11 PM, Etienne B. Racine <
Post by Etienne B. Racine
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am)
--
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-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Juliet Hannah
2012-12-23 16:17:57 UTC
Permalink
X-Received: by 10.50.11.196 with SMTP id s4mr7271817igb.9.1356279480771;
Sun, 23 Dec 2012 08:18:00 -0800 (PST)
X-BeenThere: ggplot2-/***@public.gmane.org
Received: by 10.50.76.202 with SMTP id m10ls4813671igw.26.gmail; Sun, 23 Dec
2012 08:17:57 -0800 (PST)
X-Received: by 10.42.41.9 with SMTP id n9mr14840137ice.29.1356279477849;
Sun, 23 Dec 2012 08:17:57 -0800 (PST)
X-Received: by 10.42.41.9 with SMTP id n9mr14840136ice.29.1356279477840;
Sun, 23 Dec 2012 08:17:57 -0800 (PST)
Received: from mail-ob0-f179.google.com (mail-ob0-f179.google.com [209.85.214.179])
by gmr-mx.google.com with ESMTPS id vb13si1416947igb.2.2012.12.23.08.17.57
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 23 Dec 2012 08:17:57 -0800 (PST)
Received-SPF: pass (google.com: domain of juliet.hannah-***@public.gmane.org designates 209.85.214.179 as permitted sender) client-ip=209.85.214.179;
Received: by mail-ob0-f179.google.com with SMTP id x4so6056487obh.38
for <ggplot2-/***@public.gmane.org>; Sun, 23 Dec 2012 08:17:57 -0800 (PST)
Received: by 10.182.3.144 with SMTP id c16mr16165538obc.42.1356279477562; Sun,
23 Dec 2012 08:17:57 -0800 (PST)
Received: by 10.76.130.235 with HTTP; Sun, 23 Dec 2012 08:17:57 -0800 (PST)
In-Reply-To: <CADv2QyFn6MtoOJr+BycW=0tqa0e7f7AwioPZk35iu4HTS5znBA-JsoAwUIsXosN+***@public.gmane.org>
X-Original-Sender: juliet.hannah-***@public.gmane.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com:
domain of juliet.hannah-***@public.gmane.org designates 209.85.214.179 as permitted
sender) smtp.mail=juliet.hannah-***@public.gmane.org; dkim=pass header.i=@gmail.com
Precedence: list
Mailing-list: list ggplot2-/***@public.gmane.org; contact ggplot2+owners-/***@public.gmane.org
List-ID: <ggplot2.googlegroups.com>
X-Google-Group-Id: 604545605438
List-Post: <http://groups.google.com/group/ggplot2/post?hl=en>, <mailto:ggplot2-/***@public.gmane.org>
List-Help: <http://groups.google.com/support/?hl=en>, <mailto:ggplot2+help-/***@public.gmane.org>
List-Archive: <http://groups.google.com/group/ggplot2?hl=en>
Sender: ggplot2-/***@public.gmane.org
List-Subscribe: <http://groups.google.com/group/ggplot2/subscribe?hl=en>, <mailto:ggplot2+subscribe-/***@public.gmane.org>
List-Unsubscribe: <http://groups.google.com/group/ggplot2/subscribe?hl=en>, <mailto:googlegroups-manage+604545605438+unsubscribe-/***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.r.ggplot2/6693>

All,

Any suggestions on where I'm going wrong ?

qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))

Error in theme(panel.margin = unit(1, "cm")) :
could not find function "unit"
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.9.3

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4 plyr_1.8
[10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
scales_0.2.3 stringr_0.6.1
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
Brandon Hurr
2012-12-23 17:51:01 UTC
Permalink
require(grid)
Post by Juliet Hannah
All,
Any suggestions on where I'm going wrong ?
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
could not find function "unit"
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
[1] stats graphics grDevices utils datasets methods base
[1] ggplot2_0.9.3
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4 plyr_1.8
[10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
scales_0.2.3 stringr_0.6.1
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
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-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Dennis Murphy
2012-12-23 21:21:19 UTC
Permalink
X-Received: by 10.50.47.228 with SMTP id g4mr5217826ign.12.1356297684500;
Sun, 23 Dec 2012 13:21:24 -0800 (PST)
X-BeenThere: ggplot2-/***@public.gmane.org
Received: by 10.50.36.133 with SMTP id q5ls8221988igj.29.canary; Sun, 23 Dec
2012 13:21:19 -0800 (PST)
X-Received: by 10.42.121.66 with SMTP id i2mr15308278icr.28.1356297679355;
Sun, 23 Dec 2012 13:21:19 -0800 (PST)
X-Received: by 10.42.121.66 with SMTP id i2mr15308277icr.28.1356297679344;
Sun, 23 Dec 2012 13:21:19 -0800 (PST)
Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177])
by gmr-mx.google.com with ESMTPS id vb13si1455903igb.2.2012.12.23.13.21.19
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 23 Dec 2012 13:21:19 -0800 (PST)
Received-SPF: pass (google.com: domain of djmuser-***@public.gmane.org designates 209.85.214.177 as permitted sender) client-ip=209.85.214.177;
Received: by mail-ob0-f177.google.com with SMTP id uo13so6125534obb.22
for <ggplot2-/***@public.gmane.org>; Sun, 23 Dec 2012 13:21:19 -0800 (PST)
Received: by 10.182.194.2 with SMTP id hs2mr16183931obc.97.1356297679216; Sun,
23 Dec 2012 13:21:19 -0800 (PST)
Received: by 10.76.93.71 with HTTP; Sun, 23 Dec 2012 13:21:19 -0800 (PST)
In-Reply-To: <CALzuZRT4dBKOL+6Ti9EeKqAMbeinXLj6M70LeE22cLwaxGLDDQ-JsoAwUIsXosN+***@public.gmane.org>
X-Original-Sender: djmuser-***@public.gmane.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com:
domain of djmuser-***@public.gmane.org designates 209.85.214.177 as permitted sender)
smtp.mail=djmuser-***@public.gmane.org; dkim=pass header.i=@gmail.com
Precedence: list
Mailing-list: list ggplot2-/***@public.gmane.org; contact ggplot2+owners-/***@public.gmane.org
List-ID: <ggplot2.googlegroups.com>
X-Google-Group-Id: 604545605438
List-Post: <http://groups.google.com/group/ggplot2/post?hl=en>, <mailto:ggplot2-/***@public.gmane.org>
List-Help: <http://groups.google.com/support/?hl=en>, <mailto:ggplot2+help-/***@public.gmane.org>
List-Archive: <http://groups.google.com/group/ggplot2?hl=en>
Sender: ggplot2-/***@public.gmane.org
List-Subscribe: <http://groups.google.com/group/ggplot2/subscribe?hl=en>, <mailto:ggplot2+subscribe-/***@public.gmane.org>
List-Unsubscribe: <http://groups.google.com/group/ggplot2/subscribe?hl=en>, <mailto:googlegroups-manage+604545605438+unsubscribe-/***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.r.ggplot2/6696>

Hi Juliet:

Load the grid package and try again. This is becoming a ggplot2 FAQ :)

Dennis
Post by Juliet Hannah
All,
Any suggestions on where I'm going wrong ?
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
could not find function "unit"
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
[1] stats graphics grDevices utils datasets methods base
[1] ggplot2_0.9.3
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4 plyr_1.8
[10] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
scales_0.2.3 stringr_0.6.1
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
Ben Bolker
2012-12-23 22:20:32 UTC
Permalink
Post by Juliet Hannah
All,
Any suggestions on where I'm going wrong ?
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
could not find function "unit"
library(grid)
Tim Keitt
2015-04-08 17:35:19 UTC
Permalink
Post by Ben Bolker
Post by Juliet Hannah
All,
Any suggestions on where I'm going wrong ?
qplot(mpg / 100, wt, data = mtcars, facets = vs ~ am) +
theme(panel.margin = unit(1, "cm"))
could not find function "unit"
library(grid)
Or better grid::unit(1, "cm). (Hi Ben)

THK
--
--
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 ***@googlegroups.com
To unsubscribe: email ggplot2+***@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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...