SPSS-Style ggplot2 Theme

Description

A complete ggplot2 theme that mimics the appearance of SPSS charts, optimized for HTML output. Supports both modern (v24+) and legacy (<v24) SPSS styles.

Usage

theme_SPSS(
  base_size = 14,
  base_family = "sans",
  base_line_size = 0.75,
  base_rect_size = 0.75,
  version = "modern",
  scales = "continuous",
  scale.x = scales,
  scale.y = scales
)

Arguments

base_size Numeric. Base font size in points. Default 14.
base_family Character. Base font family. Default “sans” (web-safe).
base_line_size Numeric. Base line width. Default 0.75.
base_rect_size Numeric. Base rectangle border width. Default 0.75.
version Character. “modern” (default) for SPSS v24+ style with white background and horizontal grid lines, or “legacy” for older SPSS style with grey background and box border.
scales Character. “continuous” (default) or “discrete” for both axes. Controls axis text sizing.
scale.x Character. Override scale type for x-axis only.
scale.y Character. Override scale type for y-axis only.

Value

A ggplot2 ggplot2::theme() object (complete theme).

Examples

library("psych350lab")

library(ggplot2)

# Basic usage with modern style
ggplot(superman, aes(x = clark_height, y = lois_height)) +
  geom_point() +
  theme_SPSS()

# Legacy SPSS style
ggplot(superman, aes(x = clark_height, y = lois_height)) +
  geom_point() +
  theme_SPSS(version = "legacy")

# With discrete x-axis
ggplot(superman, aes(x = factor(type), y = lois_height)) +
  geom_boxplot() +
  theme_SPSS(scale.x = "discrete")