Skip to contents

Creates a custom ggplot2 theme based on Insper's visual identity and branding. This theme provides a clean, professional appearance with customizable grid lines and border options, using Insper's color palette and typography.

Usage

theme_insper(
  base_size = 12,
  font_title = "Georgia",
  font_text = "Inter",
  grid = TRUE,
  border = "none",
  align = "panel",
  ...
)

Arguments

base_size

Numeric. Base font size for all text elements in points. Default is 12. All other text sizes are calculated relative to this value.

font_title

Character. Font family to use for plot titles and subtitles. Default is "Georgia" (serif, from Insper's official template). The theme automatically detects font availability and falls back to "EB Garamond", then "Playfair Display", then "serif" if unavailable.

font_text

Character. Font family to use for all other text elements (axis labels, legend text, etc.). Default is "Inter" (sans-serif, from Insper's official template). Falls back to "Arial" then "sans" if unavailable.

grid

Logical. Whether to display major grid lines. If TRUE, shows dashed grid lines in light gray. If FALSE, removes all grid lines. Default is TRUE.

border

Character. Type of plot border to display. Must be one of:

  • "none" - No border or axis lines (default)

  • "half" - Shows axis lines with ticks but no full border

  • "closed" - Shows a complete rectangular border around the plot area

align

Character. Alignment of title and caption. Must be one of:

  • "panel" - Align to the plot panel area (default)

  • "plot" - Align to the entire plot area including margins

...

Additional arguments passed to theme_minimal().

Value

A ggplot2 theme object that can be added to ggplot objects using the + operator.

Details

The theme applies Insper's visual identity through:

  • Off-white background color for both plot and panel

  • Horizontal legend positioned at the top

  • Bold legend titles

  • Custom color scheme using get_insper_colors() function

  • Consistent spacing and typography hierarchy

**Fonts:**

The theme uses fonts based on Insper's official template:

  • Georgia (serif, system font) for titles - falls back to EB Garamond, then Playfair Display

  • Inter (sans-serif) for body text - falls back to Arial

Inter, EB Garamond, and Playfair Display are bundled with the package and registered automatically when the package is loaded. Georgia is a system font available on most operating systems. If any font is unavailable, the theme falls back through the chain to system defaults ("serif" / "sans").

The function validates input parameters and will throw an error if invalid values are provided for grid or border arguments.

See also

Examples

if (FALSE) { # has_insper_fonts()
library(ggplot2)

# Default
ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_insper()

# Minimal — no grid, clean background
ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_insper(grid = FALSE)

# Presentation — larger text for slides
ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_insper(base_size = 16, grid = FALSE)

# Print / PDF — closed border, smaller text
ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  theme_insper(base_size = 11, border = "closed")
}