I am hoping someone can help out with custom text labels in grid.arrange
. I have four plots that I am arranging in a column with a shared legend below. I am trying to change the font of the "left" label in grid.arrange
but I cannot figure out how textGrob
works for this. My current code (with p1
-p4
as ggplot
objects) is:
windowsFonts(Georgia=windowsFont("TT Georgia"))
plots <- list(p1, p2, p3, p4)
g <- ggplotGrob(plots[[1]])
leftText <- textGrob("Percent Savings", rot=90, gp=gpar(font="Georgia"))
grid.arrange(
do.call(arrangeGrob, c(plots, nrow=4)),
left = leftText,
top = " ",
ncol = 1,
heights = c(8))
The font in the legend changes correctly, but the left-side font remains the default. I have tried both font="Georgia"
and family="Georgia"
. Any ideas how I can get this to work?
Edit: For anyone else having this problem, I finally stumbled across an answer, in textGrob the command is not font
or family
. It is, in fact, fontfamily
.
As the OP noted, the grid parameter is called fontfamily,
grid.text("haha", gp=gpar(fontfamily = "Zapfino", cex=5))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With