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.
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
.
ggplot2
and extrafont
packages :install.packages("ggplot2")
install.packages("extrafont")
Rttf2
using the remotes
package :install.packages("remotes")
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
extrafont::font_import(path = "_fonts/")
jtheme
directly from GitHub :install.packages(
pkgs = "https://github.com/jeremieboudreault/jtheme/raw/main/_bin/jtheme_0.0.2.tar.gz",
repos = NULL
)
jtheme
by simply adding it to your ggplot2
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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.