From 4f015cbd63293d51b489a6d9d25673735d9cf85c Mon Sep 17 00:00:00 2001 From: Pedro Aphalo Date: Mon, 1 Jul 2024 00:36:42 +0300 Subject: [PATCH] Add missing conditional execution of 'ggrepel' An object was created in a chunk run only with 'ggrepel' available, but used in unprotected chunks. In addition found additional unprotected chunks calling 'ggrepel'. --- DESCRIPTION | 4 +- NEWS.md | 4 +- man/ggpp-package.Rd | 2 + vignettes/nudge-examples.R | 12 +- vignettes/nudge-examples.Rmd | 15 +- vignettes/nudge-examples.html | 764 +++++++++++++++++----------------- 6 files changed, 399 insertions(+), 402 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f33a352..f33c2a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: ggpp Type: Package Title: Grammar Extensions to 'ggplot2' -Version: 0.5.8 -Date: 2024-06-26 +Version: 0.5.8-1 +Date: 2024-06-30 Authors@R: c( person("Pedro J.", "Aphalo", email = "pedro.aphalo@helsinki.fi", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3385-972X")), diff --git a/NEWS.md b/NEWS.md index 5147ba6..0e7f9fa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,10 +6,12 @@ editor_options: wrap: 72 --- -# ggpp 0.5.8 +# ggpp 0.5.8-1 - Fix wrong test for availability of 'gginnards' in examples (reported by _Joshua Ulrich_ in issue #53). +- Add to vignette _Combining repulsion and nudging_ three missing tests for +availability of package 'ggrepel'. - Revise `position_nudge_to()` to support expansion and contraction of the range within which to spread the positions. diff --git a/man/ggpp-package.Rd b/man/ggpp-package.Rd index 5c35d9e..7c5e7c9 100644 --- a/man/ggpp-package.Rd +++ b/man/ggpp-package.Rd @@ -6,6 +6,8 @@ \alias{ggpp-package} \title{ggpp: Grammar Extensions to 'ggplot2'} \description{ +\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} + Extensions to 'ggplot2' respecting the grammar of graphics paradigm. Geometries: geom_table(), geom_plot() and geom_grob() add insets to plots using native data coordinates, while geom_table_npc(), geom_plot_npc() and geom_grob_npc() do the same using "npc" coordinates through new aesthetics "npcx" and "npcy". Statistics: select observations based on 2D density. Positions: radial nudging away from a center point and nudging away from a line or curve; combined stacking and nudging; combined dodging and nudging. } \details{ diff --git a/vignettes/nudge-examples.R b/vignettes/nudge-examples.R index f0e6676..87c06e6 100644 --- a/vignettes/nudge-examples.R +++ b/vignettes/nudge-examples.R @@ -55,13 +55,14 @@ ggplot(df, aes(x, y, label = l)) + hjust = "left") + expand_limits(x = 2.3) -## ----eval=eval_ggrepel-------------------------------------------------------- +## ----------------------------------------------------------------------------- ## Example data frame where each species' principal components have been computed. df1 <- data.frame( Species = paste("Species",1:5), PC1 = c(-4, -3.5, 1, 2, 3), PC2 = c(-1, -1, 0, -0.5, 0.7)) +## ----eval=eval_ggrepel-------------------------------------------------------- ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + geom_hline(aes(yintercept = 0), linewidth = .2) + geom_vline(aes(xintercept = 0), linewidth = .2) + @@ -78,7 +79,7 @@ ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + coord_fixed() + theme(legend.position = "none") -## ----------------------------------------------------------------------------- +## ----eval=eval_ggrepel-------------------------------------------------------- ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + geom_hline(aes(yintercept = 0), linewidth = .2) + geom_vline(aes(xintercept = 0), linewidth = .2) + @@ -350,14 +351,11 @@ ggplot(data = d, aes(x, y, label = lab, colour = group)) + geom_point() ## ----------------------------------------------------------------------------- -library(ggplot2) -library(ggpp) -library(ggrepel) syms = c(letters[1:5], LETTERS[1:5], 0:9) labs = do.call(paste0, expand.grid(syms, syms)) dset = data.frame(x=rnorm(1e3), y=rnorm(1e3), label=sample(labs, 1e3, replace=TRUE)) -## ----------------------------------------------------------------------------- +## ----eval=eval_ggrepel-------------------------------------------------------- ggplot(dset, aes(x=x, y=y, label = label)) + geom_point(colour = "grey85") + stat_dens2d_filter(geom = "text_repel", @@ -466,7 +464,7 @@ ggplot(df, aes(x, yy)) + box.padding = 0, min.segment.length = 0) -## ----------------------------------------------------------------------------- +## ----eval=eval_ggrepel-------------------------------------------------------- ggplot(df, aes(x, yy)) + geom_point() + stat_smooth(method = "lm", diff --git a/vignettes/nudge-examples.Rmd b/vignettes/nudge-examples.Rmd index 3742bc9..37e2d63 100644 --- a/vignettes/nudge-examples.Rmd +++ b/vignettes/nudge-examples.Rmd @@ -243,16 +243,18 @@ respective default justification approaches. --- -A usually more problematic example is the labeling of loadings in PCA +A usually more problematic example is the labelling of loadings in PCA and similar biplots. -```{r, eval=eval_ggrepel} +```{r} ## Example data frame where each species' principal components have been computed. df1 <- data.frame( Species = paste("Species",1:5), PC1 = c(-4, -3.5, 1, 2, 3), PC2 = c(-1, -1, 0, -0.5, 0.7)) +``` +```{r, eval=eval_ggrepel} ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + geom_hline(aes(yintercept = 0), linewidth = .2) + geom_vline(aes(xintercept = 0), linewidth = .2) + @@ -273,7 +275,7 @@ ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + The use of `position_nudge_center()` together with repulsion, shown above, results a much better plot than using only repulsion. -```{r} +```{r, eval=eval_ggrepel} ggplot(df1, aes(x=PC1, y = PC2, label = Species, colour = Species)) + geom_hline(aes(yintercept = 0), linewidth = .2) + geom_vline(aes(xintercept = 0), linewidth = .2) + @@ -696,15 +698,12 @@ GitHub by Michael Schubert, made possible by parameter `keep.these` added for this and similar use cases. ```{r} -library(ggplot2) -library(ggpp) -library(ggrepel) syms = c(letters[1:5], LETTERS[1:5], 0:9) labs = do.call(paste0, expand.grid(syms, syms)) dset = data.frame(x=rnorm(1e3), y=rnorm(1e3), label=sample(labs, 1e3, replace=TRUE)) ``` -```{r} +```{r, eval=eval_ggrepel} ggplot(dset, aes(x=x, y=y, label = label)) + geom_point(colour = "grey85") + stat_dens2d_filter(geom = "text_repel", @@ -909,7 +908,7 @@ Nudging plus repulsion, shown next, will be compared to alternatives. In this case we assume no linking segments are desired as there is enough space for the data labels to remain near the observations. -```{r} +```{r, eval=eval_ggrepel} ggplot(df, aes(x, yy)) + geom_point() + stat_smooth(method = "lm", diff --git a/vignettes/nudge-examples.html b/vignettes/nudge-examples.html index 7c5e42f..04df00e 100644 --- a/vignettes/nudge-examples.html +++ b/vignettes/nudge-examples.html @@ -12,7 +12,7 @@ - + Combining repulsion and nudging @@ -51,7 +51,7 @@