Hi,
I'm using the gridExtra package to combine some graphs like in the
arrangeGrob example. Each of the graphs has a title but they appear much
larger than the overall combined plot title and left axis label. Does anyone
know how I can control the style / size of the gridExtra labels?
library(gridExtra)
library(ggplot2)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
p1 <- qplot(carat, price, data=dsamp, colour=clarity)
p2 <- qplot(carat, price, data=dsamp, colour=clarity, geom="path")
tmp <- ggplot_gtable(ggplot_build(p1))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
grid.arrange(arrangeGrob(p1 + theme(legend.position="none") +
ggtitle("Scatter Plot"),
p2 + theme(legend.position="none") +
ggtitle("Line Plot"),
main ="this is a title",
left = "This is my global Y-axis
title"), legend,
widths=unit.c(unit(1, "npc") - legend$width,
legend$width), nrow=1)
--
View this message in context: http://r.789695.n4.nabble.com/Styling-gridExtra-s-title-and-left-labels-tp4639388.html
Sent from the R help mailing list archive at Nabble.com.
Styling gridExtra's title and left labels
2 messages · Alastair, Baptiste Auguie
Hi,
You can use a grob instead of a text string, e.g
main = textGrob("Title goes here", gp=gpar(fontsize=24))
HTH,
b.
On 7 August 2012 03:49, Alastair <alastair.andrew at gmail.com> wrote:
Hi,
I'm using the gridExtra package to combine some graphs like in the
arrangeGrob example. Each of the graphs has a title but they appear much
larger than the overall combined plot title and left axis label. Does anyone
know how I can control the style / size of the gridExtra labels?
library(gridExtra)
library(ggplot2)
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
p1 <- qplot(carat, price, data=dsamp, colour=clarity)
p2 <- qplot(carat, price, data=dsamp, colour=clarity, geom="path")
tmp <- ggplot_gtable(ggplot_build(p1))
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
legend <- tmp$grobs[[leg]]
grid.arrange(arrangeGrob(p1 + theme(legend.position="none") +
ggtitle("Scatter Plot"),
p2 + theme(legend.position="none") +
ggtitle("Line Plot"),
main ="this is a title",
left = "This is my global Y-axis
title"), legend,
widths=unit.c(unit(1, "npc") - legend$width,
legend$width), nrow=1)
--
View this message in context: http://r.789695.n4.nabble.com/Styling-gridExtra-s-title-and-left-labels-tp4639388.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.