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.
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
.
- Install
ggplot2
andextrafont
packages :
install.packages("ggplot2")
install.packages("extrafont")
- Install
Rttf2
using theremotes
package :
install.packages("remotes")
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
- Import the Source Sans Pro font into R :
extrafont::font_import(path = "_fonts/")
- 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
)
- You can start using
jtheme
by simply adding it to yourggplot2
plots :
library(jtheme)
ggplot() + ... + jtheme()
Note : All examples are from fake 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
)
+ 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
)
+ 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
)
+ jtheme(
show_grid = TRUE # Add a grid in the plot
)
+ jtheme(
show_grid = TRUE, # Add a grid in the plot
borders = "all" # Add complete borders
)