theme_ds4psy {ds4psy} | R Documentation |
A basic and flexible plot theme (using ggplot2 and unikn).
Description
theme_ds4psy
provides a generic ds4psy theme
to use in ggplot2 commands.
Usage
theme_ds4psy(
base_size = 11,
base_family = "",
base_line_size = base_size/22,
base_rect_size = base_size/22,
col_title = grey(0, 1),
col_txt_1 = grey(0.1, 1),
col_txt_2 = grey(0.2, 1),
col_txt_3 = grey(0.1, 1),
col_bgrnd = "transparent",
col_panel = grey(1, 1),
col_strip = "transparent",
col_axes = grey(0, 1),
col_gridx = grey(0.75, 1),
col_gridy = grey(0.75, 1),
col_brdrs = "transparent"
)
Arguments
base_size |
Base font size (optional, numeric).
Default: |
base_family |
Base font family (optional, character).
Default: |
base_line_size |
Base line size (optional, numeric).
Default: |
base_rect_size |
Base rectangle size (optional, numeric).
Default: |
col_title |
Color of plot title (and tag).
Default: |
col_txt_1 |
Color of primary text (headings and axis labels).
Default: |
col_txt_2 |
Color of secondary text (caption, legend, axes labels/ticks).
Default: |
col_txt_3 |
Color of other text (facet strip labels).
Default: |
col_bgrnd |
Color of plot background.
Default: |
col_panel |
Color of panel background(s).
Default: |
col_strip |
Color of facet strips.
Default: |
col_axes |
Color of (x and y) axes.
Default: |
col_gridx |
Color of (major and minor) panel lines (through x/vertical).
Default: |
col_gridy |
Color of (major and minor) panel lines (through y/horizontal).
Default: |
col_brdrs |
Color of (panel and strip) borders.
Default: |
Details
The theme is lightweight and no-nonsense, but somewhat opinionated (e.g., in using transparency and grid lines, and relying on grey tones for emphasizing data with color accents).
Basic sizes and the colors of text elements, backgrounds, and lines can be specified. However, excessive customization rarely yields aesthetic improvements over the standard ggplot2 themes.
Value
A ggplot2 theme.
See Also
unikn::theme_unikn
inspired the current theme.
Other plot functions:
plot_charmap()
,
plot_chars()
,
plot_fn()
,
plot_fun()
,
plot_n()
,
plot_text()
,
plot_tiles()
,
theme_clean()
,
theme_empty()
Examples
# Plotting iris dataset (using ggplot2 and unikn):
library('ggplot2') # theme_ds4psy() requires ggplot2
library('unikn') # for colors and usecol() function
ggplot(datasets::iris) +
geom_jitter(aes(x = Petal.Length, y = Petal.Width, color = Species), size = 3, alpha = 2/3) +
scale_color_manual(values = usecol(pal = c(Pinky, Seeblau, Seegruen))) +
labs(title = "Iris petals",
subtitle = "The subtitle of this plot",
caption = "Data from datasets::iris") +
theme_ds4psy()
ggplot(datasets::iris) +
geom_jitter(aes(x = Sepal.Length, y = Sepal.Width, color = Species), size = 3, alpha = 2/3) +
facet_wrap(~Species) +
scale_color_manual(values = usecol(pal = c(Pinky, Seeblau, Seegruen))) +
labs(tag = "A",
title = "Iris sepals",
subtitle = "Demo plot with facets and default colors",
caption = "Data from datasets::iris") +
coord_fixed(ratio = 3/2) +
theme_ds4psy()
# A unikn::Seeblau look:
ggplot(datasets::iris) +
geom_jitter(aes(x = Sepal.Length, y = Sepal.Width, color = Species), size = 3, alpha = 2/3) +
facet_wrap(~Species) +
scale_color_manual(values = usecol(pal = c(Pinky, Seeblau, Seegruen))) +
labs(tag = "B",
title = "Iris sepals",
subtitle = "Demo plot in unikn::Seeblau colors",
caption = "Data from datasets::iris") +
coord_fixed(ratio = 3/2) +
theme_ds4psy(col_title = pal_seeblau[[4]], col_strip = pal_seeblau[[1]], col_brdrs = Grau)