From c042173d14a045d76bcc02fb34dd4c3614bb46a0 Mon Sep 17 00:00:00 2001 From: Alboukadel Kassambara Date: Wed, 24 May 2017 00:40:01 +0200 Subject: [PATCH] fix for #31 --- R/fviz.R | 2 +- R/fviz_add.R | 8 +++++--- man/fviz_add.Rd | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/R/fviz.R b/R/fviz.R index e816076..6badad9 100644 --- a/R/fviz.R +++ b/R/fviz.R @@ -255,7 +255,7 @@ fviz <- function(X, element, axes = c(1, 2), geom = "auto", if(!is.null(esup)) p <- .add_supp (p, X, element = esup$name, axes = axes, select = select, geom = geom, color = esup$color, shape = esup$shape, pointsize = pointsize, labelsize = labelsize, addlabel = esup$addlabel, repel = repel, linetype = 2, - scale. = scale., ca_map = ca_map) + scale. = scale., ca_map = ca_map, ...) p <- .fviz_finish(p, X, axes, axes.linetype, ...) + diff --git a/R/fviz_add.R b/R/fviz_add.R index 4db22ba..f206925 100644 --- a/R/fviz_add.R +++ b/R/fviz_add.R @@ -16,6 +16,7 @@ #' @param linetype the linetype to be used when geom ="arrow" #' @param repel a boolean, whether to use ggrepel to avoid overplotting text #' labels or not. +#' @param font.family character vector specifying font family. #' @param ... Additional arguments, not used #' @return a ggplot2 plot #' @author Alboukadel Kassambara \email{alboukadel.kassambara@@gmail.com} @@ -41,7 +42,7 @@ #' @export fviz_add <- function(ggp, df, axes = c(1,2), geom=c("point", "arrow"), color ="blue", addlabel = TRUE, labelsize = 4, pointsize = 2, shape=19, linetype ="dashed", - repel = FALSE, ...) + repel = FALSE, font.family = "", ...) { # Deprecated arguments extra_args <- list(...) @@ -89,12 +90,13 @@ fviz_add <- function(ggp, df, axes = c(1,2), geom=c("point", "arrow"), color ="b if(addlabel | "text" %in% geom){ if(repel){ p <- p + ggpubr::geom_exec(ggrepel::geom_text_repel, data = df, x = "x", y = "y", - label = "name", color = color, size = labelsize) + label = "name", color = color, size = labelsize, + family = font.family) } else{ p <- p + ggpubr::geom_exec(geom_text, data = df, x = "x", y = "y", label = "name", color = color, size = labelsize, - vjust=vjust, hjust = hjust) + vjust=vjust, hjust = hjust, family = font.family) # p <- p + geom_text(data = df, aes_string("x", "y"), color = color, # label = df$name, size = labelsize, vjust=vjust, hjust = hjust) diff --git a/man/fviz_add.Rd b/man/fviz_add.Rd index 3a9e763..3d84ca0 100644 --- a/man/fviz_add.Rd +++ b/man/fviz_add.Rd @@ -6,7 +6,7 @@ \usage{ fviz_add(ggp, df, axes = c(1, 2), geom = c("point", "arrow"), color = "blue", addlabel = TRUE, labelsize = 4, pointsize = 2, - shape = 19, linetype = "dashed", repel = FALSE, ...) + shape = 19, linetype = "dashed", repel = FALSE, font.family = "", ...) } \arguments{ \item{ggp}{a ggplot2 plot.} @@ -33,6 +33,8 @@ Allowed values are "point" or "arrow" or "text"} \item{repel}{a boolean, whether to use ggrepel to avoid overplotting text labels or not.} +\item{font.family}{character vector specifying font family.} + \item{...}{Additional arguments, not used} } \value{