Learn R Programming

factoextra (version 2.2.0)

theme_factoextra: A clean publication theme for factoextra plots

Description

A ggplot2 theme tuned for the dimension-reduction scatter plots and biplots produced by the fviz_*() functions: a light, unobtrusive coordinate grid (so points can be read against the axes), a clean background, and de-emphasized axis lines. Pass it through the ggtheme argument, e.g. fviz_pca_ind(res, ggtheme = theme_factoextra()), or add it to any returned plot with + theme_factoextra().

Read more: ggplot2 Themes in R: Customize the Look.

Usage

theme_factoextra(base_size = 12, base_family = "")

Value

A ggplot2 theme object.

Arguments

base_size

base font size, in points.

base_family

base font family.

Details

The fviz_* functions have different default themes (fviz_pca_* use theme_minimal(), fviz_cluster() uses theme_grey(), fviz_dend() uses theme_classic(), ...). For one consistent look across several plots in the same document, pass ggtheme = theme_factoextra() to each call (see the last example) rather than relying on ggplot2::theme_set(), which the fviz_* functions override with their explicit ggtheme default.

See Also

factoextra_palette. Online tutorial: ggplot2 Themes in R: Customize the Look.

Examples

Run this code
# \donttest{
data(iris)
res.pca <- prcomp(iris[, 1:4], scale. = TRUE)
fviz_pca_ind(res.pca, habillage = iris$Species,
             palette = factoextra_palette("okabe"),
             ggtheme = theme_factoextra())

# or add it to an existing plot
fviz_pca_var(res.pca) + theme_factoextra()

# a consistent look across the family: pass the same ggtheme to each call
km <- kmeans(scale(iris[, 1:4]), 3)
fviz_pca_ind(res.pca, ggtheme = theme_factoextra())
fviz_cluster(km, data = iris[, 1:4], ggtheme = theme_factoextra())
# }

Run the code above in your browser using DataLab