Skip to content

Commit

Permalink
Merge branch 'main' into radiate + correct le roux name
Browse files Browse the repository at this point in the history
  • Loading branch information
corybrunson committed Dec 30, 2024
2 parents a4e29ee + 0c36b1c commit f49f6ad
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 43 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export(stat_spantree)
export(stat_star)
export(svd_ord)
export(theme_biplot)
export(theme_scaffold)
export(tidy)
export(transmute_cols)
export(transmute_rows)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ The 'projection' referential stat prepares segment endpoints between `x,y` posit

A new 'rule' statistical transformation computes additional position aesthetics that the 'axis' geom uses to limit and offset axes. The stat is referential and expects a set of functions that compute limits `lower` and `upper` along the axes and `yintercept` and `xintercept` associated with offset axes. The 'axis' geom preprocesses these aesthetics to rule endpoints `xmin,ymin,xmax,ymax` and offset vectors `xend,yend` to force the plotting window to contain the limited axis segments or, if the axes remain lines, the offsets where they are centered.

## scaffold theme

The 'biplot' theme has been renamed 'scaffold', with an alias for backward compatibility.

# ordr 0.1.1

## `linewidth` aesthetic (breaking change)
Expand Down
2 changes: 1 addition & 1 deletion R/stat-rule.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#' @example inst/examples/ex-stat-rule-glass.r
#' @export
stat_rule <- function(
mapping = NULL, data = NULL, geom = "axis", position = "identity",
mapping = NULL, data = NULL, geom = "rule", position = "identity",
fun.lower = "minpp", fun.upper = "maxpp",
fun.offset = "minabspp",
fun.args = list(),
Expand Down
29 changes: 19 additions & 10 deletions R/themes.r
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
#' @title Biplot theme
#' @title Scaffolding theme
#'
#' @description Omit coordinate visual aids from biplots.
#' @description Omit cartesian coordinate visual aids.
#'
#' @details
#' @details Geometric data analysis concerns the intrinsic geometry of data.
#' Analyses often use artificial or arbitrary coordinate systems that carry no
#' useful interpretation but instead serve as scaffolding, especially for
#' graphical elements like [axes][geom_axis] that represent other variables
#' (Gardner, 2001). In such cases, the visual aids (tick marks and labels,
#' grid lines) used to recover the coordinates of the row and column markers
#' would add unnecessary clutter and should be omitted. This partial theme
#' updates the current theme by removing these elements. The biplot theme is
#' an alias included for convenience and backward compatibility.
#'
#' Because the artificial axes often go uninterpreted, biplots may omit the
#' visual aids (tick marks and labels, grid lines) used to recover the
#' artificial coordinates of the row and column markers The biplot (partial)
#' theme removes these elements from the current theme. This can be especially
#' helpful when plotting [axes][geom_axis()] or [isolines][geom_isoline()].
#'

#' @template ref-gardner2001

#' @return A ggplot [theme][ggplot2::theme].
#' @export
theme_biplot <- function() {
theme_scaffold <- function() {
theme(
axis.ticks = element_blank(),
axis.text = element_blank(),
panel.grid = element_blank()
)
}

#' @rdname theme_scaffold
#' @export
theme_biplot <- theme_scaffold
4 changes: 2 additions & 2 deletions R/zzz-biplot-stats.r
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ StatRowsRule <- ggproto(
stat_rows_rule <- function(
mapping = NULL,
data = NULL,
geom = "axis",
geom = "rule",
position = "identity",
fun.lower = "minpp",
fun.upper = "maxpp",
Expand Down Expand Up @@ -596,7 +596,7 @@ StatColsRule <- ggproto(
stat_cols_rule <- function(
mapping = NULL,
data = NULL,
geom = "axis",
geom = "rule",
position = "identity",
fun.lower = "minpp",
fun.upper = "maxpp",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ origin:

``` r
ggbiplot(iris_pca, axis.type = "predictive", axis.percents = FALSE) +
theme_biplot() +
theme_scaffold() +
geom_rows_point(aes(color = Species, shape = Species)) +
stat_rows_center(
aes(color = Species, shape = Species),
Expand Down Expand Up @@ -312,7 +312,7 @@ monograph
[*Biplots*](https://www.google.com/books/edition/Biplots/lTxiedIxRpgC)
and the textbook [*Understanding
Biplots*](https://www.wiley.com/en-us/Understanding+Biplots-p-9781119972907)
by John C. Gower, David J. Hand, Sugnet Gardner–Lubbe, and Niel J. Le
by John C. Gower, David J. Hand, Sugnet Gardner–Lubbe, and Niël J. Le
Roux, and by the volume [*Principal Components
Analysis*](https://link.springer.com/book/10.1007/b98835) by I. T.
Jolliffe.
Expand Down
4 changes: 2 additions & 2 deletions README.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ For legibility, the axes are limited to the data range and offset from the origi

```{r predictive biplot}
ggbiplot(iris_pca, axis.type = "predictive", axis.percents = FALSE) +
theme_biplot() +
theme_scaffold() +
geom_rows_point(aes(color = Species, shape = Species)) +
stat_rows_center(
aes(color = Species, shape = Species),
Expand Down Expand Up @@ -167,7 +167,7 @@ This package was originally inspired by the **ggbiplot** extension developed by
The motivation to unify a variety of ordination methods came from several books and articles by [Michael Greenacre](https://www.fbbva.es/microsite/multivariate-statistics/resources.html), in particular [_Biplots in Practice_](https://www.fbbva.es/microsite/multivariate-statistics/resources.html#biplots).
Several answers at CrossValidated, in particular by [amoeba](https://stats.stackexchange.com/users/28666/amoeba) and [ttnphns](https://stats.stackexchange.com/users/3277/ttnphns), provided theoretical insights and informed design choices.
Thomas Lin Pedersen's [**tidygraph**](https://github.com/thomasp85/tidygraph) prequel to **ggraph** finally induced the shift from the downstream generation of scatterplots to the upstream handling and manipulating of models.
Additional design elements and features have been informed by the monograph [_Biplots_](https://www.google.com/books/edition/Biplots/lTxiedIxRpgC) and the textbook [_Understanding Biplots_](https://www.wiley.com/en-us/Understanding+Biplots-p-9781119972907) by John C. Gower, David J. Hand, Sugnet Gardner--Lubbe, and Niel J. Le Roux, and by the volume [_Principal Components Analysis_](https://link.springer.com/book/10.1007/b98835) by I. T. Jolliffe.
Additional design elements and features have been informed by the monograph [_Biplots_](https://www.google.com/books/edition/Biplots/lTxiedIxRpgC) and the textbook [_Understanding Biplots_](https://www.wiley.com/en-us/Understanding+Biplots-p-9781119972907) by John C. Gower, David J. Hand, Sugnet Gardner--Lubbe, and Niël J. Le Roux, and by the volume [_Principal Components Analysis_](https://link.springer.com/book/10.1007/b98835) by I. T. Jolliffe.

### exposition

Expand Down
2 changes: 1 addition & 1 deletion inst/examples/ex-stat-rule-glass.r
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ glass_lda %>%
ggbiplot() +
theme_bw() + theme_biplot() +
geom_rows_point(aes(shape = grouping, alpha = discriminant)) +
stat_cols_rule(aes(label = name), color = "#888888", num = 8L,
stat_cols_rule(aes(label = name), geom = "axis", color = "#888888", num = 8L,
fun.offset = \(x) minabspp(x, p = .1),
text_size = 2.5, text_dodge = .025) +
scale_shape_manual(values = c(16L, 17L, 15L, 18L)) +
Expand Down
6 changes: 6 additions & 0 deletions man-roxygen/ref-gardner2001.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @references
#'
#' Gardner S (2001) _Extensions of biplot methodology to discriminant analysis
#' with applications of non-parametric principal components_. PhD thesis,
#' Stellenbosch University. <http://hdl.handle.net/10019.1/52264>
#'
4 changes: 2 additions & 2 deletions man/biplot-stats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-interpolative biplot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-model components and scree plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-predictive biplot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions man/stat_rule.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/theme_biplot.Rd

This file was deleted.

33 changes: 33 additions & 0 deletions man/theme_scaffold.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f49f6ad

Please sign in to comment.