diff --git a/DESCRIPTION b/DESCRIPTION index 42a2607c..cd008277 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -77,7 +77,6 @@ Collate: 'geom-intervals.r' 'geom-isoline.r' 'geom-origin.r' - 'geom-text-radiate.r' 'geom-utils.r' 'geom-vector.r' 'methods-base-eigen.r' diff --git a/NAMESPACE b/NAMESPACE index 9bdf742f..1dae1949 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -189,7 +189,6 @@ export(GeomIsoline) export(GeomLineranges) export(GeomOrigin) export(GeomPointranges) -export(GeomTextRadiate) export(GeomUnitCircle) export(GeomVector) export(StatCenter) @@ -239,7 +238,6 @@ export(geom_cols_point) export(geom_cols_pointranges) export(geom_cols_polygon) export(geom_cols_text) -export(geom_cols_text_radiate) export(geom_cols_text_repel) export(geom_cols_vector) export(geom_isoline) @@ -257,10 +255,8 @@ export(geom_rows_point) export(geom_rows_pointranges) export(geom_rows_polygon) export(geom_rows_text) -export(geom_rows_text_radiate) export(geom_rows_text_repel) export(geom_rows_vector) -export(geom_text_radiate) export(geom_text_repel) export(geom_unit_circle) export(geom_vector) diff --git a/R/geom-text-radiate.r b/R/geom-text-radiate.r deleted file mode 100644 index cf0d8927..00000000 --- a/R/geom-text-radiate.r +++ /dev/null @@ -1,110 +0,0 @@ -#' @title Text radiating outward from the origin -#' - -#' @description `geom_text_radiate()` is adapted from `ggbiplot()` in the -#' off-CRAN extensions of the same name (Vu, 2014; Telford, 2017; Gegzna, -#' 2018). It renders text at specified positions and angles that radiate out -#' from the origin. -#' @template biplot-layers - -#' @section Aesthetics: - -#' `geom_text_radiate()` understands the following aesthetics (required -#' aesthetics are in bold): - -#' - **`x`** -#' - **`y`** -#' - **`label`** -#' - `alpha` -#' - `angle` -#' - `colour` -#' - `family` -#' - `fontface` -#' - `hjust` -#' - `lineheight` -#' - `size` -#' - `vjust` -#' - `group` -#' - -#' @template ref-ggbiplot - -#' @import ggplot2 -#' @inheritParams ggplot2::geom_text -#' @template return-layer -#' @family geom layers -#' @export -geom_text_radiate <- function( - mapping = NULL, data = NULL, stat = "identity", position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, inherit.aes = TRUE -) { - layer( - data = data, - mapping = mapping, - stat = stat, - geom = GeomTextRadiate, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - parse = parse, - check_overlap = check_overlap, - na.rm = na.rm, - ... - ) - ) -} - -#' @rdname ordr-ggproto -#' @format NULL -#' @usage NULL -#' @export -GeomTextRadiate <- ggproto( - "GeomTextRadiate", GeomText, - - draw_panel = function( - data, panel_params, coord, - parse = FALSE, - na.rm = FALSE, - check_overlap = FALSE - ) { - - if (is.character(data$hjust)) { - data$hjust <- compute_just(data$hjust, data$x) - } - data$hjust <- 0.5 + (data$hjust - 0.625 - 0.5) * sign(data$x) - data$angle <- as.numeric(data$angle) + (180 / pi) * atan(data$y / data$x) - - lab <- data$label - if (parse) { - lab <- parse_safe(as.character(lab)) - } - - data <- coord$transform(data, panel_params) - if (is.character(data$vjust)) { - data$vjust <- compute_just(data$vjust, data$y) - } - if (is.character(data$hjust)) { - data$hjust <- compute_just(data$hjust, data$x) - } - - grid::textGrob( - lab, - data$x, data$y, default.units = "native", - hjust = data$hjust, vjust = data$vjust, - rot = data$angle, - gp = grid::gpar( - col = alpha(data$colour, data$alpha), - fontsize = data$size * .pt, - fontfamily = data$family, - fontface = data$fontface, - lineheight = data$lineheight - ), - check.overlap = check_overlap - ) - } -) diff --git a/R/geom-vector.r b/R/geom-vector.r index 64e7522e..064b08a6 100644 --- a/R/geom-vector.r +++ b/R/geom-vector.r @@ -1,7 +1,10 @@ #' @title Vectors from the origin #' -#' @description `geom_vector()` renders arrows from the origin to points. +#' @description `geom_vector()` renders arrows from the origin to points, +#' optionally with text radiating outward. This layer is adapted from +#' `ggbiplot()` in the off-CRAN extensions of the same name (Vu, 2014; +#' Telford, 2017; Gegzna, 2018). #' @template biplot-layers #' @section Aesthetics: @@ -14,22 +17,32 @@ #' - `alpha` #' - `colour` #' - `linetype` +#' - `label` #' - `size` +#' - `angle`, `hjust`, `vjust` +#' - `label_colour`, `label_alpha` +#' - `family`, `fontface`, `lineheight` #' - `group` #' +#' @template ref-ggbiplot + #' @import ggplot2 #' @inheritParams ggplot2::layer +#' @inheritParams ggplot2::geom_segment #' @template param-geom #' @param arrow Specification for arrows, as created by [grid::arrow()], or else #' `NULL` for no arrows. +#' @param vector_labels Logical; whether to include labels radiating outward +#' from the vectors. #' @template return-layer #' @family geom layers #' @example inst/examples/ex-geom-vector-iris.r #' @export geom_vector <- function( mapping = NULL, data = NULL, stat = "identity", position = "identity", - arrow = default_arrow, + arrow = default_arrow, lineend = "round", linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -43,8 +56,9 @@ geom_vector <- function( show.legend = show.legend, inherit.aes = inherit.aes, params = list( + arrow = arrow, lineend = lineend, linejoin = linejoin, + vector_labels = vector_labels, na.rm = na.rm, - arrow = arrow, ... ) ) @@ -55,9 +69,17 @@ geom_vector <- function( #' @usage NULL #' @export GeomVector <- ggproto( - "GeomVector", GeomSegment, + "GeomVector", Geom, required_aes = c("x", "y"), + non_missing_aes = c("xend", "yend", "linetype", "linewidth", "angle"), + + default_aes = aes( + colour = "black", linewidth = 0.5, linetype = 1, alpha = NA, + label = "", size = 3.88, angle = 0, hjust = .5, vjust = .5, + label_colour = "black", label_alpha = NA, + family = "", fontface = 1, lineheight = 1.2 + ), setup_data = function(data, params) { # all vectors have tails at the origin @@ -69,20 +91,76 @@ GeomVector <- ggproto( draw_panel = function( data, panel_params, coord, - arrow = default_arrow, - lineend = "round", linejoin = "mitre", + vector_labels = TRUE, + arrow = default_arrow, lineend = "round", linejoin = "mitre", + parse = FALSE, check_overlap = FALSE, na.rm = FALSE ) { + if (! coord$is_linear()) { warning("Vectors are not yet tailored to non-linear coordinates.") } + + # initialize grob list + grobs <- list() + # reverse ends of `arrow` if (! is.null(arrow)) arrow$ends <- c(2L, 1L, 3L)[arrow$ends] - GeomSegment$draw_panel( + grobs <- c(grobs, list(GeomSegment$draw_panel( data = data, panel_params = panel_params, coord = coord, arrow = arrow, lineend = lineend, linejoin = linejoin, na.rm = na.rm - ) + ))) + + if (vector_labels) { + label_data <- data + + # specify aesthetics (if necessary) + label_data$colour <- label_data$label_colour + label_data$alpha <- label_data$label_alpha + label_data$label_colour <- label_data$label_alpha <- NULL + + if (is.character(label_data$hjust)) { + label_data$hjust <- compute_just(label_data$hjust, label_data$x) + } + label_data$hjust <- + 0.5 + (label_data$hjust - 0.625 - 0.5) * sign(label_data$x) + label_data$angle <- + as.numeric(label_data$angle) + + (180 / pi) * atan(label_data$y / label_data$x) + + lab <- label_data$label + if (parse) { + lab <- parse_safe(as.character(lab)) + } + + label_data <- coord$transform(label_data, panel_params) + if (is.character(label_data$vjust)) { + label_data$vjust <- compute_just(label_data$vjust, label_data$y) + } + if (is.character(label_data$hjust)) { + label_data$hjust <- compute_just(label_data$hjust, label_data$x) + } + + grobs <- c(grobs, list(grid::textGrob( + lab, + label_data$x, label_data$y, default.units = "native", + hjust = label_data$hjust, vjust = label_data$vjust, + rot = label_data$angle, + gp = grid::gpar( + col = alpha(label_data$colour, label_data$alpha), + fontsize = label_data$size * .pt, + fontfamily = label_data$family, + fontface = label_data$fontface, + lineheight = label_data$lineheight + ), + check.overlap = check_overlap + ))) + } + + grob <- do.call(grid::grobTree, grobs) + grob$name <- grid::grobName(grob, "geom_vector") + grob } ) diff --git a/R/zzz-biplot-geoms.r b/R/zzz-biplot-geoms.r index 8fe4acc5..4b4cd030 100644 --- a/R/zzz-biplot-geoms.r +++ b/R/zzz-biplot-geoms.r @@ -33,7 +33,6 @@ #' @inheritParams geom_lineranges #' @inheritParams geom_pointranges #' @inheritParams geom_isoline -#' @inheritParams geom_text_radiate #' @inheritParams geom_vector NULL @@ -239,6 +238,7 @@ geom_rows_text <- function( nudge_x = 0, nudge_y = 0, check_overlap = FALSE, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -261,6 +261,7 @@ geom_rows_text <- function( params = list( parse = parse, check_overlap = check_overlap, + size.unit = size.unit, na.rm = na.rm, ... ) @@ -279,6 +280,7 @@ geom_cols_text <- function( nudge_x = 0, nudge_y = 0, check_overlap = FALSE, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -301,6 +303,7 @@ geom_cols_text <- function( params = list( parse = parse, check_overlap = check_overlap, + size.unit = size.unit, na.rm = na.rm, ... ) @@ -321,6 +324,7 @@ geom_rows_label <- function( label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -345,6 +349,7 @@ geom_rows_label <- function( label.padding = label.padding, label.r = label.r, label.size = label.size, + size.unit = size.unit, na.rm = na.rm, ... ) @@ -365,6 +370,7 @@ geom_cols_label <- function( label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -389,6 +395,7 @@ geom_cols_label <- function( label.padding = label.padding, label.r = label.r, label.size = label.size, + size.unit = size.unit, na.rm = na.rm, ... ) @@ -951,68 +958,6 @@ geom_cols_isoline <- function( ) } -#' @rdname biplot-geoms -#' @export -geom_rows_text_radiate <- function( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) { - layer( - mapping = mapping, - data = data, - stat = rows_stat(stat), - geom = GeomTextRadiate, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - parse = parse, - check_overlap = check_overlap, - na.rm = na.rm, - ... - ) - ) -} - -#' @rdname biplot-geoms -#' @export -geom_cols_text_radiate <- function( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) { - layer( - mapping = mapping, - data = data, - stat = cols_stat(stat), - geom = GeomTextRadiate, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - parse = parse, - check_overlap = check_overlap, - na.rm = na.rm, - ... - ) - ) -} - #' @rdname biplot-geoms #' @export geom_rows_vector <- function( @@ -1021,6 +966,9 @@ geom_rows_vector <- function( stat = "identity", position = "identity", arrow = default_arrow, + lineend = "round", + linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, @@ -1036,6 +984,9 @@ geom_rows_vector <- function( inherit.aes = inherit.aes, params = list( arrow = arrow, + lineend = lineend, + linejoin = linejoin, + vector_labels = vector_labels, na.rm = na.rm, ... ) @@ -1050,6 +1001,9 @@ geom_cols_vector <- function( stat = "identity", position = "identity", arrow = default_arrow, + lineend = "round", + linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, @@ -1065,6 +1019,9 @@ geom_cols_vector <- function( inherit.aes = inherit.aes, params = list( arrow = arrow, + lineend = lineend, + linejoin = linejoin, + vector_labels = vector_labels, na.rm = na.rm, ... ) diff --git a/README.md b/README.md index d99bcb56..844ec097 100644 --- a/README.md +++ b/README.md @@ -229,8 +229,7 @@ appropriate subsets:[^8] ggbiplot(iris_pca, sec.axes = "cols", scale.factor = 2) + geom_rows_point(aes(color = Species, shape = Species)) + stat_rows_ellipse(aes(color = Species), alpha = .5, level = .99) + - geom_cols_vector() + - geom_cols_text_radiate(aes(label = name)) + + geom_cols_vector(aes(label = name)) + expand_limits(y = c(-3.5, NA)) + ggtitle("PCA of Anderson's iris measurements", "99% confidence ellipses; variables use top & right axes") diff --git a/README.rmd b/README.rmd index 767b26ff..c1fa7748 100644 --- a/README.rmd +++ b/README.rmd @@ -120,8 +120,7 @@ Following **ggplot2**, the `fortify()` method row-binds the factor tibbles with ggbiplot(iris_pca, sec.axes = "cols", scale.factor = 2) + geom_rows_point(aes(color = Species, shape = Species)) + stat_rows_ellipse(aes(color = Species), alpha = .5, level = .99) + - geom_cols_vector() + - geom_cols_text_radiate(aes(label = name)) + + geom_cols_vector(aes(label = name)) + expand_limits(y = c(-3.5, NA)) + ggtitle("PCA of Anderson's iris measurements", "99% confidence ellipses; variables use top & right axes") diff --git a/build-pre/build-layers.r b/build-pre/build-layers.r index ae812ffd..b87a4b65 100644 --- a/build-pre/build-layers.r +++ b/build-pre/build-layers.r @@ -63,7 +63,7 @@ param_trans <- c( # necessary internal functions not exported from their home packages # -+- currently only put in geoms file; need to distinguish -+- get_from <- c( - # `geom_text_radiate()` + # `geom_vector()` compute_just = "ggplot2", # `geom_text_repel()` to_unit = "ggrepel" diff --git a/inst/examples/ex-fun-lda-iris.r b/inst/examples/ex-fun-lda-iris.r index 720a366c..0c36f587 100644 --- a/inst/examples/ex-fun-lda-iris.r +++ b/inst/examples/ex-fun-lda-iris.r @@ -22,8 +22,7 @@ iris_lda %>% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Unstandardized coefficient biplot of iris LDA") + expand_limits(y = c(-3, 5)) @@ -57,8 +56,7 @@ iris_lda %>% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Standardized coefficient biplot of iris LDA") + expand_limits(y = c(-2, 3)) @@ -88,8 +86,7 @@ iris_lda %>% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Contribution biplot of iris LDA") + expand_limits(y = c(-2, 3.5)) diff --git a/inst/examples/ex-geom-isoline-glass.r b/inst/examples/ex-geom-isoline-glass.r index dc881d8a..fbcc796a 100644 --- a/inst/examples/ex-geom-isoline-glass.r +++ b/inst/examples/ex-geom-isoline-glass.r @@ -14,8 +14,7 @@ glass_lda %>% ggbiplot(aes(label = name), elements = "active") + theme_bw() + theme_biplot() + geom_rows_text() + - geom_cols_vector(subset = c(1, 3, 4)) + - geom_cols_text_radiate(subset = c(1, 3, 4), size = 3) + + geom_cols_vector(subset = c(1, 3, 4), size = 3) + geom_cols_isoline(subset = c(1, 3, 4), alpha = .25, num = 4L, label_dodge = -.03, text_alpha = .5, text_size = 3) + ggtitle( diff --git a/inst/examples/ex-geom-unit-circle-glass.r b/inst/examples/ex-geom-unit-circle-glass.r index 4929bdad..d1981276 100644 --- a/inst/examples/ex-geom-unit-circle-glass.r +++ b/inst/examples/ex-geom-unit-circle-glass.r @@ -15,5 +15,4 @@ glass_pca %>% theme_biplot() + geom_rows_point(aes(color = site, shape = form), alpha = .5) + geom_unit_circle(alpha = .5, scale.factor = 3) + - geom_cols_vector() + - geom_cols_text_radiate() + geom_cols_vector() diff --git a/inst/examples/ex-geom-vector-iris.r b/inst/examples/ex-geom-vector-iris.r index 68172968..3a5d4a01 100644 --- a/inst/examples/ex-geom-vector-iris.r +++ b/inst/examples/ex-geom-vector-iris.r @@ -8,7 +8,6 @@ iris_pca %>% scale_color_brewer(type = "qual", palette = 2) + geom_unit_circle() + geom_rows_point(alpha = .5) + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = name), color = "#444444") + + geom_cols_vector(aes(label = name), color = "#444444") + ggtitle("Row-principal unscaled PCA biplot of Anderson iris measurements") + expand_limits(y = c(NA, 2)) diff --git a/inst/examples/ex-ggbiplot-key-iris.r b/inst/examples/ex-ggbiplot-key-iris.r index 2c9fda73..cd98a347 100644 --- a/inst/examples/ex-ggbiplot-key-iris.r +++ b/inst/examples/ex-ggbiplot-key-iris.r @@ -10,8 +10,7 @@ iris[, -5] %>% scale_color_brewer(type = "qual", palette = 2) + geom_rows_lineranges(fun.data = mean_sdl, linewidth = .75) + geom_rows_point(alpha = .5) + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = name), color = "#444444", size = 3) + + geom_cols_vector(aes(label = name), color = "#444444", size = 3) + ggtitle( "Row-principal PCA biplot of Anderson iris data", "Ranges 2 sample standard deviations from centroids" diff --git a/inst/examples/ex-ggbiplot-lm-mtcars.r b/inst/examples/ex-ggbiplot-lm-mtcars.r index 6ce4fe85..58992106 100644 --- a/inst/examples/ex-ggbiplot-lm-mtcars.r +++ b/inst/examples/ex-ggbiplot-lm-mtcars.r @@ -25,7 +25,6 @@ ggbiplot(mtcars_specs_pca, aes(label = name), theme_minimal() + geom_rows_text(size = 3) + geom_cols_vector(data = mtcars_pca_lm) + - geom_cols_text_radiate(data = mtcars_pca_lm) + expand_limits(x = c(-2.5, 2)) # multidimensional scaling based on a scaled cosine distance of vehicle specs @@ -65,5 +64,4 @@ ggbiplot(mtcars_specs_cmds_ord, aes(label = name), theme_minimal() + geom_rows_text(size = 3) + geom_cols_vector(data = mtcars_cmds_lm) + - geom_cols_text_radiate(data = mtcars_cmds_lm) + expand_limits(x = c(-2.25, 1.25), y = c(-2, 1.5)) diff --git a/inst/examples/ex-ggbiplot-secaxis-iris.r b/inst/examples/ex-ggbiplot-secaxis-iris.r index 687743c2..1082b1da 100644 --- a/inst/examples/ex-ggbiplot-secaxis-iris.r +++ b/inst/examples/ex-ggbiplot-secaxis-iris.r @@ -13,8 +13,7 @@ iris_pca %>% theme_bw() + scale_color_brewer(type = "qual", palette = 2) + geom_rows_point() + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = measure), color = "#444444") + + geom_cols_vector(aes(label = measure), color = "#444444") + ggtitle( "Row-principal PCA biplot of Anderson iris measurements", "Variable loadings scaled to secondary axes" @@ -27,8 +26,7 @@ iris_pca %>% theme_bw() + scale_color_brewer(type = "qual", palette = 2) + geom_rows_point() + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = measure), color = "#444444") + + geom_cols_vector(aes(label = measure), color = "#444444") + ggtitle( "Row-principal PCA biplot of Anderson iris measurements", "Variable loadings scaled to secondary axes" diff --git a/inst/examples/ex-methods-cancor-savings.r b/inst/examples/ex-methods-cancor-savings.r index 80ccc92c..229bf0d9 100644 --- a/inst/examples/ex-methods-cancor-savings.r +++ b/inst/examples/ex-methods-cancor-savings.r @@ -31,5 +31,4 @@ savings_cca %>% ggbiplot(aes(label = name), sec.axes = "cols", scale.factor = 5L) + theme_biplot() + geom_cols_vector(elements = "active") + - geom_cols_text_radiate(elements = "active") + geom_rows_text(elements = "score", subset = seq(50L)) diff --git a/inst/examples/ex-methods-factanal-swiss.r b/inst/examples/ex-methods-factanal-swiss.r index c21b5cf8..1c06f94e 100644 --- a/inst/examples/ex-methods-factanal-swiss.r +++ b/inst/examples/ex-methods-factanal-swiss.r @@ -20,6 +20,5 @@ head(get_rows(swiss_fa, elements = "score")) swiss_fa %>% ggbiplot() + theme_bw() + - geom_cols_vector(aes(color = uniqueness)) + - geom_cols_text_radiate(aes(label = name)) + + geom_cols_vector(aes(color = uniqueness, label = name)) + expand_limits(x = c(-2, 2.5), y = c(-1.5, 2)) diff --git a/inst/examples/ex-stat-chull-spend.r b/inst/examples/ex-stat-chull-spend.r index 08547e1e..765b889a 100644 --- a/inst/examples/ex-stat-chull-spend.r +++ b/inst/examples/ex-stat-chull-spend.r @@ -7,10 +7,10 @@ USPersonalExpenditure %>% ggbiplot(aes(label = name), clip = "off", sec.axes = "cols", scale.factor = 50) + geom_rows_label(size = 3) + - geom_cols_vector() + # omit labels in the conical hull without the origin + geom_cols_vector(vector_labels = FALSE) + stat_cols_cone(linetype = "dotted") + - geom_cols_text_radiate(stat = "cone") + + geom_cols_vector(stat = "cone", vector_labels = TRUE, color = "transparent") + ggtitle( "U.S. Personal Expenditure data, 1940-1960", "Row-principal biplot of centered PCA" diff --git a/inst/examples/ex-stat-matrix-swiss.r b/inst/examples/ex-stat-matrix-swiss.r index 9bb49cc0..e56eac6d 100644 --- a/inst/examples/ex-stat-matrix-swiss.r +++ b/inst/examples/ex-stat-matrix-swiss.r @@ -11,5 +11,4 @@ ggbiplot(swiss_fa) + geom_rows_point(elements = "score") + geom_rows_text(aes(label = name), elements = "score", subset = c(1, 4, 18)) + scale_alpha_manual(values = c(0, 1), guide = "none") + - geom_cols_vector() + - geom_cols_text_radiate(aes(label = name)) + geom_cols_vector(aes(label = name)) diff --git a/man/biplot-geoms.Rd b/man/biplot-geoms.Rd index 25c500ec..67468b3e 100644 --- a/man/biplot-geoms.Rd +++ b/man/biplot-geoms.Rd @@ -24,8 +24,6 @@ \alias{geom_cols_pointranges} \alias{geom_rows_isoline} \alias{geom_cols_isoline} -\alias{geom_rows_text_radiate} -\alias{geom_cols_text_radiate} \alias{geom_rows_vector} \alias{geom_cols_vector} \title{Convenience geoms for row and column matrix factors} @@ -116,6 +114,7 @@ geom_rows_text( nudge_x = 0, nudge_y = 0, check_overlap = FALSE, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -131,6 +130,7 @@ geom_cols_text( nudge_x = 0, nudge_y = 0, check_overlap = FALSE, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -148,6 +148,7 @@ geom_rows_label( label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -165,6 +166,7 @@ geom_cols_label( label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, + size.unit = "mm", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE @@ -408,38 +410,15 @@ geom_cols_isoline( inherit.aes = TRUE ) -geom_rows_text_radiate( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) - -geom_cols_text_radiate( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) - geom_rows_vector( mapping = NULL, data = NULL, stat = "identity", position = "identity", arrow = default_arrow, + lineend = "round", + linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, @@ -452,6 +431,9 @@ geom_cols_vector( stat = "identity", position = "identity", arrow = default_arrow, + lineend = "round", + linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, @@ -546,6 +528,10 @@ the order of the data. Therefore data should be arranged by the label column before calling \code{geom_text()}. Note that this argument is not supported by \code{geom_label()}.} +\item{size.unit}{How the \code{size} aesthetic is interpreted: as millimetres +(\code{"mm"}, default), points (\code{"pt"}), centimetres (\code{"cm"}), inches (\code{"in"}), +or picas (\code{"pc"}).} + \item{label.padding}{Amount of padding around label. Defaults to 0.25 lines.} \item{label.r}{Radius of rounded corners. Defaults to 0.15 lines.} @@ -611,6 +597,9 @@ or isoline, as a proportion of the minimum of the plot width and height.} \item{isoline_text}{Logical; whether to include text value marks along the isolines.} + +\item{vector_labels}{Logical; whether to include labels radiating outward +from the vectors.} } \value{ A ggproto \link[ggplot2:layer]{layer}. diff --git a/man/draw-key.Rd b/man/draw-key.Rd index f3fdffe7..8f2eb0a2 100644 --- a/man/draw-key.Rd +++ b/man/draw-key.Rd @@ -47,8 +47,7 @@ iris[, -5] \%>\% scale_color_brewer(type = "qual", palette = 2) + geom_rows_lineranges(fun.data = mean_sdl, linewidth = .75) + geom_rows_point(alpha = .5) + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = name), color = "#444444", size = 3) + + geom_cols_vector(aes(label = name), color = "#444444", size = 3) + ggtitle( "Row-principal PCA biplot of Anderson iris data", "Ranges 2 sample standard deviations from centroids" diff --git a/man/figures/README-interpolative biplot-1.png b/man/figures/README-interpolative biplot-1.png index 70182041..180f6f4e 100644 Binary files a/man/figures/README-interpolative biplot-1.png and b/man/figures/README-interpolative biplot-1.png differ diff --git a/man/figures/README-model components and scree plot-1.png b/man/figures/README-model components and scree plot-1.png index e653fd67..7333e270 100644 Binary files a/man/figures/README-model components and scree plot-1.png and b/man/figures/README-model components and scree plot-1.png differ diff --git a/man/figures/README-predictive biplot-1.png b/man/figures/README-predictive biplot-1.png index a454e5c7..ffd54634 100644 Binary files a/man/figures/README-predictive biplot-1.png and b/man/figures/README-predictive biplot-1.png differ diff --git a/man/geom_axis.Rd b/man/geom_axis.Rd index 7adf5498..4a6ad878 100644 --- a/man/geom_axis.Rd +++ b/man/geom_axis.Rd @@ -212,7 +212,6 @@ Other geom layers: \code{\link{geom_isoline}()}, \code{\link{geom_lineranges}()}, \code{\link{geom_origin}()}, -\code{\link{geom_text_radiate}()}, \code{\link{geom_vector}()} } \concept{geom layers} diff --git a/man/geom_isoline.Rd b/man/geom_isoline.Rd index 2a49e0d4..d8800c21 100644 --- a/man/geom_isoline.Rd +++ b/man/geom_isoline.Rd @@ -162,8 +162,7 @@ glass_lda \%>\% ggbiplot(aes(label = name), elements = "active") + theme_bw() + theme_biplot() + geom_rows_text() + - geom_cols_vector(subset = c(1, 3, 4)) + - geom_cols_text_radiate(subset = c(1, 3, 4), size = 3) + + geom_cols_vector(subset = c(1, 3, 4), size = 3) + geom_cols_isoline(subset = c(1, 3, 4), alpha = .25, num = 4L, label_dodge = -.03, text_alpha = .5, text_size = 3) + ggtitle( @@ -178,7 +177,6 @@ Other geom layers: \code{\link{geom_axis}()}, \code{\link{geom_lineranges}()}, \code{\link{geom_origin}()}, -\code{\link{geom_text_radiate}()}, \code{\link{geom_vector}()} } \concept{geom layers} diff --git a/man/geom_lineranges.Rd b/man/geom_lineranges.Rd index e06d608f..d960cb86 100644 --- a/man/geom_lineranges.Rd +++ b/man/geom_lineranges.Rd @@ -156,7 +156,6 @@ Other geom layers: \code{\link{geom_axis}()}, \code{\link{geom_isoline}()}, \code{\link{geom_origin}()}, -\code{\link{geom_text_radiate}()}, \code{\link{geom_vector}()} } \concept{geom layers} diff --git a/man/geom_origin.Rd b/man/geom_origin.Rd index 5a46d1ff..c76b46f1 100644 --- a/man/geom_origin.Rd +++ b/man/geom_origin.Rd @@ -126,15 +126,13 @@ glass_pca \%>\% theme_biplot() + geom_rows_point(aes(color = site, shape = form), alpha = .5) + geom_unit_circle(alpha = .5, scale.factor = 3) + - geom_cols_vector() + - geom_cols_text_radiate() + geom_cols_vector() } \seealso{ Other geom layers: \code{\link{geom_axis}()}, \code{\link{geom_isoline}()}, \code{\link{geom_lineranges}()}, -\code{\link{geom_text_radiate}()}, \code{\link{geom_vector}()} } \concept{geom layers} diff --git a/man/geom_text_radiate.Rd b/man/geom_text_radiate.Rd deleted file mode 100644 index b9233b39..00000000 --- a/man/geom_text_radiate.Rd +++ /dev/null @@ -1,181 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geom-text-radiate.r -\name{geom_text_radiate} -\alias{geom_text_radiate} -\title{Text radiating outward from the origin} -\usage{ -geom_text_radiate( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - parse = FALSE, - check_overlap = FALSE, - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) -} -\arguments{ -\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}}. If specified and -\code{inherit.aes = TRUE} (the default), it is combined with the default mapping -at the top level of the plot. You must supply \code{mapping} if there is no plot -mapping.} - -\item{data}{The data to be displayed in this layer. There are three -options: - -If \code{NULL}, the default, the data is inherited from the plot -data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}. - -A \code{data.frame}, or other object, will override the plot -data. All objects will be fortified to produce a data frame. See -\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created. - -A \code{function} will be called with a single argument, -the plot data. The return value must be a \code{data.frame}, and -will be used as the layer data. A \code{function} can be created -from a \code{formula} (e.g. \code{~ head(.x, 10)}).} - -\item{stat}{The statistical transformation to use on the data for this layer. -When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used the override the default coupling between geoms and -stats. The \code{stat} argument accepts the following: -\itemize{ -\item A \code{Stat} ggproto subclass, for example \code{StatCount}. -\item A string naming the stat. To give the stat as a string, strip the -function name of the \code{stat_} prefix. For example, to use \code{stat_count()}, -give the stat as \code{"count"}. -\item For more information and other ways to specify the stat, see the -\link[ggplot2:layer_stats]{layer stat} documentation. -}} - -\item{position}{A position adjustment to use on the data for this layer. -Cannot be jointy specified with \code{nudge_x} or \code{nudge_y}. This -can be used in various ways, including to prevent overplotting and -improving the display. The \code{position} argument accepts the following: -\itemize{ -\item The result of calling a position function, such as \code{position_jitter()}. -\item A string nameing the position adjustment. To give the position as a -string, strip the function name of the \code{position_} prefix. For example, -to use \code{position_jitter()}, give the position as \code{"jitter"}. -\item For more information and other ways to specify the position, see the -\link[ggplot2:layer_positions]{layer position} documentation. -}} - -\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These -arguments broadly fall into one of 4 categories below. Notably, further -arguments to the \code{position} argument, or aesthetics that are required -can \emph{not} be passed through \code{...}. Unknown arguments that are not part -of the 4 categories below are ignored. -\itemize{ -\item Static aesthetics that are not mapped to a scale, but are at a fixed -value and apply to the layer as a whole. For example, \code{colour = "red"} -or \code{linewidth = 3}. The geom's documentation has an \strong{Aesthetics} -section that lists the available options. The 'required' aesthetics -cannot be passed on to the \code{params}. Please note that while passing -unmapped aesthetics as vectors is technically possible, the order and -required length is not guaranteed to be parallel to the input data. -\item When constructing a layer using -a \verb{stat_*()} function, the \code{...} argument can be used to pass on -parameters to the \code{geom} part of the layer. An example of this is -\code{stat_density(geom = "area", outline.type = "both")}. The geom's -documentation lists which parameters it can accept. -\item Inversely, when constructing a layer using a -\verb{geom_*()} function, the \code{...} argument can be used to pass on parameters -to the \code{stat} part of the layer. An example of this is -\code{geom_area(stat = "density", adjust = 0.5)}. The stat's documentation -lists which parameters it can accept. -\item The \code{key_glyph} argument of \code{\link[ggplot2:layer]{layer()}} may also be passed on through -\code{...}. This can be one of the functions described as -\link[ggplot2:draw_key]{key glyphs}, to change the display of the layer in the legend. -}} - -\item{parse}{If \code{TRUE}, the labels will be parsed into expressions and -displayed as described in \code{?plotmath}.} - -\item{check_overlap}{If \code{TRUE}, text that overlaps previous text in the -same layer will not be plotted. \code{check_overlap} happens at draw time and in -the order of the data. Therefore data should be arranged by the label -column before calling \code{geom_text()}. Note that this argument is not -supported by \code{geom_label()}.} - -\item{na.rm}{If \code{FALSE}, the default, missing values are removed with -a warning. If \code{TRUE}, missing values are silently removed.} - -\item{show.legend}{logical. Should this layer be included in the legends? -\code{NA}, the default, includes if any aesthetics are mapped. -\code{FALSE} never includes, and \code{TRUE} always includes. -It can also be a named logical vector to finely select the aesthetics to -display.} - -\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, -rather than combining with them. This is most useful for helper functions -that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} -} -\value{ -A ggproto \link[ggplot2:layer]{layer}. -} -\description{ -\code{geom_text_radiate()} is adapted from \code{ggbiplot()} in the -off-CRAN extensions of the same name (Vu, 2014; Telford, 2017; Gegzna, -2018). It renders text at specified positions and angles that radiate out -from the origin. -} -\section{Biplot layers}{ - -\code{\link[=ggbiplot]{ggbiplot()}} uses \code{\link[ggplot2:fortify]{ggplot2::fortify()}} internally to produce a single data -frame with a \code{.matrix} column distinguishing the subjects (\code{"rows"}) and -variables (\code{"cols"}). The stat layers \code{stat_rows()} and \code{stat_cols()} simply -filter the data frame to one of these two. - -The geom layers \verb{geom_rows_*()} and \verb{geom_cols_*()} call the corresponding -stat in order to render plot elements for the corresponding factor matrix. -\verb{geom_dims_*()} selects a default matrix based on common practice, e.g. -points for rows and arrows for columns. -} - -\section{Aesthetics}{ - -\code{geom_text_radiate()} understands the following aesthetics (required -aesthetics are in bold): -\itemize{ -\item \strong{\code{x}} -\item \strong{\code{y}} -\item \strong{\code{label}} -\item \code{alpha} -\item \code{angle} -\item \code{colour} -\item \code{family} -\item \code{fontface} -\item \code{hjust} -\item \code{lineheight} -\item \code{size} -\item \code{vjust} -\item \code{group} -} -} - -\references{ -Vincent Q. Vu (2014). ggbiplot: A 'ggplot2' based biplot. R package version -0.55. \url{https://github.com/vqv/ggbiplot}, \code{experimental} branch - -Richard J Telford (2017). ggbiplot: A 'ggplot2' based biplot. R package -version 0.6. \url{https://github.com/richardjtelford/ggbiplot} (fork), -\code{experimental} branch - -Vilmantas Gegzna (2018). ggbiplot: A 'ggplot2' based biplot. R package -version 0.55. \url{https://github.com/forked-packages/ggbiplot} (fork), \code{experimental} -branch -} -\seealso{ -Other geom layers: -\code{\link{geom_axis}()}, -\code{\link{geom_isoline}()}, -\code{\link{geom_lineranges}()}, -\code{\link{geom_origin}()}, -\code{\link{geom_vector}()} -} -\concept{geom layers} diff --git a/man/geom_vector.Rd b/man/geom_vector.Rd index 71680396..3701862e 100644 --- a/man/geom_vector.Rd +++ b/man/geom_vector.Rd @@ -10,6 +10,9 @@ geom_vector( stat = "identity", position = "identity", arrow = default_arrow, + lineend = "round", + linejoin = "mitre", + vector_labels = TRUE, ..., na.rm = FALSE, show.legend = NA, @@ -66,6 +69,13 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \item{arrow}{Specification for arrows, as created by \code{\link[grid:arrow]{grid::arrow()}}, or else \code{NULL} for no arrows.} +\item{lineend}{Line end style (round, butt, square).} + +\item{linejoin}{Line join style (round, mitre, bevel).} + +\item{vector_labels}{Logical; whether to include labels radiating outward +from the vectors.} + \item{...}{Additional arguments passed to \code{\link[ggplot2:layer]{ggplot2::layer()}}.} \item{na.rm}{Passed to \code{\link[ggplot2:layer]{ggplot2::layer()}}.} @@ -85,7 +95,10 @@ the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} A ggproto \link[ggplot2:layer]{layer}. } \description{ -\code{geom_vector()} renders arrows from the origin to points. +\code{geom_vector()} renders arrows from the origin to points, +optionally with text radiating outward. This layer is adapted from +\code{ggbiplot()} in the off-CRAN extensions of the same name (Vu, 2014; +Telford, 2017; Gegzna, 2018). } \section{Biplot layers}{ @@ -110,7 +123,11 @@ are in bold): \item \code{alpha} \item \code{colour} \item \code{linetype} +\item \code{label} \item \code{size} +\item \code{angle}, \code{hjust}, \code{vjust} +\item \code{label_colour}, \code{label_alpha} +\item \code{family}, \code{fontface}, \code{lineheight} \item \code{group} } } @@ -126,17 +143,27 @@ iris_pca \%>\% scale_color_brewer(type = "qual", palette = 2) + geom_unit_circle() + geom_rows_point(alpha = .5) + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = name), color = "#444444") + + geom_cols_vector(aes(label = name), color = "#444444") + ggtitle("Row-principal unscaled PCA biplot of Anderson iris measurements") + expand_limits(y = c(NA, 2)) } +\references{ +Vincent Q. Vu (2014). ggbiplot: A 'ggplot2' based biplot. R package version +0.55. \url{https://github.com/vqv/ggbiplot}, \code{experimental} branch + +Richard J Telford (2017). ggbiplot: A 'ggplot2' based biplot. R package +version 0.6. \url{https://github.com/richardjtelford/ggbiplot} (fork), +\code{experimental} branch + +Vilmantas Gegzna (2018). ggbiplot: A 'ggplot2' based biplot. R package +version 0.55. \url{https://github.com/forked-packages/ggbiplot} (fork), \code{experimental} +branch +} \seealso{ Other geom layers: \code{\link{geom_axis}()}, \code{\link{geom_isoline}()}, \code{\link{geom_lineranges}()}, -\code{\link{geom_origin}()}, -\code{\link{geom_text_radiate}()} +\code{\link{geom_origin}()} } \concept{geom layers} diff --git a/man/ggbiplot.Rd b/man/ggbiplot.Rd index cc93f930..2fb52f8e 100644 --- a/man/ggbiplot.Rd +++ b/man/ggbiplot.Rd @@ -141,8 +141,7 @@ iris_pca \%>\% theme_bw() + scale_color_brewer(type = "qual", palette = 2) + geom_rows_point() + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = measure), color = "#444444") + + geom_cols_vector(aes(label = measure), color = "#444444") + ggtitle( "Row-principal PCA biplot of Anderson iris measurements", "Variable loadings scaled to secondary axes" @@ -155,8 +154,7 @@ iris_pca \%>\% theme_bw() + scale_color_brewer(type = "qual", palette = 2) + geom_rows_point() + - geom_cols_vector(color = "#444444") + - geom_cols_text_radiate(aes(label = measure), color = "#444444") + + geom_cols_vector(aes(label = measure), color = "#444444") + ggtitle( "Row-principal PCA biplot of Anderson iris measurements", "Variable loadings scaled to secondary axes" @@ -189,7 +187,6 @@ ggbiplot(mtcars_specs_pca, aes(label = name), theme_minimal() + geom_rows_text(size = 3) + geom_cols_vector(data = mtcars_pca_lm) + - geom_cols_text_radiate(data = mtcars_pca_lm) + expand_limits(x = c(-2.5, 2)) # multidimensional scaling based on a scaled cosine distance of vehicle specs @@ -229,7 +226,6 @@ ggbiplot(mtcars_specs_cmds_ord, aes(label = name), theme_minimal() + geom_rows_text(size = 3) + geom_cols_vector(data = mtcars_cmds_lm) + - geom_cols_text_radiate(data = mtcars_cmds_lm) + expand_limits(x = c(-2.25, 1.25), y = c(-2, 1.5)) # PCA of iris data iris_pca <- ordinate(iris, cols = 1:4, prcomp, scale = TRUE) diff --git a/man/lda-ord.Rd b/man/lda-ord.Rd index cfaaf4cd..0e666dcd 100644 --- a/man/lda-ord.Rd +++ b/man/lda-ord.Rd @@ -208,8 +208,7 @@ iris_lda \%>\% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Unstandardized coefficient biplot of iris LDA") + expand_limits(y = c(-3, 5)) @@ -243,8 +242,7 @@ iris_lda \%>\% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Standardized coefficient biplot of iris LDA") + expand_limits(y = c(-2, 3)) @@ -274,8 +272,7 @@ iris_lda \%>\% color = grouping, size = discriminant, alpha = discriminant )) + - geom_cols_vector(color = "#888888") + - geom_cols_text_radiate(aes(label = name), size = 3) + + geom_cols_vector(aes(label = name), color = "#888888", size = 3) + scale_color_brewer(type = "qual", palette = 2) + ggtitle("Contribution biplot of iris LDA") + expand_limits(y = c(-2, 3.5)) diff --git a/man/methods-cancor.Rd b/man/methods-cancor.Rd index 051f2d50..b9ba0896 100644 --- a/man/methods-cancor.Rd +++ b/man/methods-cancor.Rd @@ -110,7 +110,6 @@ savings_cca \%>\% ggbiplot(aes(label = name), sec.axes = "cols", scale.factor = 5L) + theme_biplot() + geom_cols_vector(elements = "active") + - geom_cols_text_radiate(elements = "active") + geom_rows_text(elements = "score", subset = seq(50L)) } \references{ diff --git a/man/methods-factanal.Rd b/man/methods-factanal.Rd index 55f18e4a..ff06e8ff 100644 --- a/man/methods-factanal.Rd +++ b/man/methods-factanal.Rd @@ -83,8 +83,7 @@ head(get_rows(swiss_fa, elements = "score")) swiss_fa \%>\% ggbiplot() + theme_bw() + - geom_cols_vector(aes(color = uniqueness)) + - geom_cols_text_radiate(aes(label = name)) + + geom_cols_vector(aes(color = uniqueness, label = name)) + expand_limits(x = c(-2, 2.5), y = c(-1.5, 2)) } \seealso{ diff --git a/man/ordr-ggproto.Rd b/man/ordr-ggproto.Rd index f692ab8c..62baaa7f 100644 --- a/man/ordr-ggproto.Rd +++ b/man/ordr-ggproto.Rd @@ -1,9 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/aaa-.r, R/coord-rect.r, R/geom-axis.r, -% R/geom-intervals.r, R/geom-isoline.r, R/geom-origin.r, -% R/geom-text-radiate.r, R/geom-vector.r, R/stat-center.r, R/stat-chull.r, -% R/stat-cone.r, R/stat-matrix.r, R/stat-scale.r, R/stat-spantree.r, -% R/zzz-biplot-stats.r +% R/geom-intervals.r, R/geom-isoline.r, R/geom-origin.r, R/geom-vector.r, +% R/stat-center.r, R/stat-chull.r, R/stat-cone.r, R/stat-matrix.r, +% R/stat-scale.r, R/stat-spantree.r, R/zzz-biplot-stats.r \docType{data} \name{ordr-ggproto} \alias{ordr-ggproto} @@ -15,7 +14,6 @@ \alias{GeomIsoline} \alias{GeomOrigin} \alias{GeomUnitCircle} -\alias{GeomTextRadiate} \alias{GeomVector} \alias{StatCenter} \alias{StatStar} diff --git a/man/stat_cone.Rd b/man/stat_cone.Rd index f06196ee..3dc52632 100644 --- a/man/stat_cone.Rd +++ b/man/stat_cone.Rd @@ -128,10 +128,10 @@ USPersonalExpenditure \%>\% ggbiplot(aes(label = name), clip = "off", sec.axes = "cols", scale.factor = 50) + geom_rows_label(size = 3) + - geom_cols_vector() + # omit labels in the conical hull without the origin + geom_cols_vector(vector_labels = FALSE) + stat_cols_cone(linetype = "dotted") + - geom_cols_text_radiate(stat = "cone") + + geom_cols_vector(stat = "cone", vector_labels = TRUE, color = "transparent") + ggtitle( "U.S. Personal Expenditure data, 1940-1960", "Row-principal biplot of centered PCA" diff --git a/man/stat_rows.Rd b/man/stat_rows.Rd index 1440f431..0d681384 100644 --- a/man/stat_rows.Rd +++ b/man/stat_rows.Rd @@ -137,8 +137,7 @@ ggbiplot(swiss_fa) + geom_rows_point(elements = "score") + geom_rows_text(aes(label = name), elements = "score", subset = c(1, 4, 18)) + scale_alpha_manual(values = c(0, 1), guide = "none") + - geom_cols_vector() + - geom_cols_text_radiate(aes(label = name)) + geom_cols_vector(aes(label = name)) } \seealso{ Other biplot layers: diff --git a/vignettes/cmds-variables.rmd b/vignettes/cmds-variables.rmd index 3b932f15..4caade38 100755 --- a/vignettes/cmds-variables.rmd +++ b/vignettes/cmds-variables.rmd @@ -268,8 +268,7 @@ c_eigen %>% ggbiplot() + theme_minimal() + geom_unit_circle() + - geom_rows_vector() + - geom_rows_text_radiate(aes(label = metric)) + + geom_rows_vector(aes(label = metric)) + scale_x_reverse(expand = expansion(add = .4)) + scale_y_continuous(expand = expansion(add = .3)) + ggtitle("Kendall correlations between university rankings", @@ -297,8 +296,7 @@ c_eigen %>% ggbiplot(aes(x = 2, y = 3)) + theme_minimal() + geom_unit_circle() + - geom_rows_vector() + - geom_rows_text_radiate(aes(label = metric)) + + geom_rows_vector(aes(label = metric)) + scale_x_continuous(expand = expansion(add = .5)) + scale_y_continuous(expand = expansion(add = .5)) + ggtitle("Kendall correlations between university rankings",