README.md

jtheme : Enhanced ggplot2 theme and functions

Welcome to jtheme, a collection of enhanced functions and a custom theme for R package ggplot2, adapted for scientific content such as papers, presentations and more.

Installation

jtheme use the Source Sans Pro, which is an open source font from Google. It needs to be installed on your system and in R. It is located in the fonts/ folder of the package. You will need the packages extrafont and Rttf2pt1 in order to get the Source Sans Pro into R properly before you can use jtheme.

  1. Install ggplot2 and extrafont packages :
install.packages("ggplot2")
install.packages("extrafont")
  1. Install Rttf2 using the remotes package :
install.packages("remotes")
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
  1. Import the Source Sans Pro font into R :
extrafont::font_import(path = "_fonts/")
  1. You can now install jtheme directly from GitHub :
install.packages(
    pkgs  = "https://github.com/jeremieboudreault/jtheme/raw/main/_bin/jtheme_0.0.2.tar.gz", 
    repos = NULL
)
  1. You can start using jtheme by simply adding it to your ggplot2 plots :
library(jtheme)
ggplot() + ... + jtheme()

Examples

Note : All examples are from fake data.

1. Histogram of temperature data

+ jtheme(
    expand_xy      = "x_only",   # Remove expanding of y-axis
    legend_pos     = "topright", # Legend at the top-right
    show_leg_title = FALSE       # Hide legend title
)

2. Times series of GHG evolution

+ jtheme(
    expand_xy      = FALSE,      # No expansion of x and y axes
    legend_pos     = "topleft",  # Legend at top-left
    show_leg_title = FALSE       # No legend title
)

3. Times series of air pollution

+ jtheme(
    expand_xy        = FALSE,      # No expansion of x and y axes
    legend_pos       = "topleft",  # Legend at top-left
    show_leg_title   = FALSE       # No legend title
    x_labs_to_months = TRUE        # Convert x-labels to months
)

4. Scatter plot of air pollution and temperature

+ jtheme(
    show_grid = TRUE  # Add a grid in the plot
)

5. Scatter plot of air pollution and temperature by facets

+ jtheme(
    show_grid = TRUE,  # Add a grid in the plot
    borders   = "all"  # Add complete borders
)



jeremieboudreault/jtheme documentation built on Jan. 29, 2023, 7:12 a.m.