knitr::opts_chunk$set(echo = TRUE)

ggessentials: My ggplot2 essential configurations used for paper figures.

Functions

Known issues with italicize.plot:

Aesthetics

Themes

Known issue with theme_umap_ge: this is a function returns a list of geom_text, geom_segment and theme_void(). Better implementation should define element_line_umap that can be used in theme(axis.line)

Installation

devtools::install_github("lch14forever/ggessentials")

Usage

library(ggessentials)

## to get a list of colors (1-17)
colors <- geGetColors(3)

data("iris")
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + 
    geom_point() +
    scale_color_manual(values=colors) +
    theme_bw_ge()

Italicize a taxon name in a plot

p <- ggplot(iris, aes(x=Species, y=Sepal.Width, color=Species)) + 
    geom_boxplot() +
    scale_color_manual(values=colors) +
    theme_bw_ge()

grid::grid.draw(italicize.plot(p, string = c('setosa', 'versicolor')))

Set theme for the current session

## preset the theme
geUseTheme('classic')
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + 
    geom_point() +
    scale_color_manual(values=colors)

Disrete color scale with scale_color_ge or scale_fill_ge

ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + 
    geom_point() +
    scale_color_ge()
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, fill=Species)) + 
    geom_point(shape=21) +
    scale_fill_ge()

Simplified axes (for UMAP plots)

ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + 
    geom_point() +
    theme_umap_ge()

Another implementation [will be replaced by theme_umap_ge soon]

g <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + 
    geom_point() +
    scale_color_manual(values=colors) +
    theme_bw_ge()
add_axes_umap(g)


lch14forever/ggessentials documentation built on Sept. 1, 2021, 7:23 a.m.