ggessentials: My ggplot2 essential configurations used for paper figures.
Functions
geUseTheme
: use a preset theme for plotting (supportbw
orclassic
at the moment)geGetColors
: get a vector of colorsitalicize.string
: italicize strings in a sentenceitalicize.plot
: italicize strings in a ggplot
Known issues with italicize.plot
:
- overwrites bold font face
Aesthetics
scale_color_ge
/scale_fill_ge
: selected color scheme
Themes
theme_bw_ge
theme_classic_ge
theme_umap_ge
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)
scale_color_ge
or scale_fill_ge
Disrete color scale with 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)