From c2b7e0ca6cd8f762493d03dfc8ad76ce9f946f55 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Sun, 24 Jan 2016 22:08:25 +0100 Subject: [PATCH 1/2] Resolve data upon extraction within ggplot_build --- R/plot-build.r | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/plot-build.r b/R/plot-build.r index d4ef2a2fda..c8b3bfa724 100644 --- a/R/plot-build.r +++ b/R/plot-build.r @@ -22,7 +22,13 @@ ggplot_build <- function(plot) { } layers <- plot$layers - layer_data <- lapply(layers, function(y) y$data) + layer_data <- lapply(layers, function(y) { + if (is.function(y$data)) { + fortify(y$data(plot$data)) + } else { + y$data + } + }) scales <- plot$scales # Apply function to layer and matching data From 26f32c76d97d4bc81a80fd47375bdf1b495eb913 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Tue, 13 Nov 2018 13:17:57 +0100 Subject: [PATCH 2/2] Fix #2687 Correct font descent calculation --- R/margins.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/margins.R b/R/margins.R index 4ddfe6135a..ce58db63de 100644 --- a/R/margins.R +++ b/R/margins.R @@ -336,7 +336,7 @@ font_descent <- function(family = "", face = "plain", size = 12, cex = 1) { descent <- descent_cache[[key]] if (is.null(descent)) { - descent <- descentDetails(textGrob( + descent <- convertHeight(grobDescent(textGrob( label = "gjpqyQ", gp = gpar( fontsize = size, @@ -344,7 +344,7 @@ font_descent <- function(family = "", face = "plain", size = 12, cex = 1) { fontfamily = family, fontface = face ) - )) + )), 'inches') descent_cache[[key]] <- descent } descent