How to create a pretty facet-boxplot with custom fonts

How to make a better boxplot with custom fonts, let’s explore this in this post, it can be used for the standard template for boxplot with facet and user defined fonts. Required R libraries: if(!require(tidyverse)){install.packages("tidyverse");library(tidyverse)} # for ggplot2 function if(!require(gapminder)){install.packages("gapminder");library(gapminder)} # for sample data if(!require(showtext)){install.packages("showtext");library(showtext)} # to import fonts Add fonts in R session font_add_google("Karla", "Karla") # adding local font font_add(family = "Helvetica", regular = "C:/Windows/Fonts/Helvetica 400.ttf") # Adding from Google fonts font_add_google("Roboto Slab", "Roboto Slab") # adding font from the web/google font font_families() ## [1] "sans" "serif" "mono" "wqy-microhei" "Karla" ## [6] "Helvetica" "Roboto Slab" Define theme for Boxplot and fonts themeBox <- function(base_family = "sans", exFont, ....

January 21, 2022 Â· 2 min Â· Dr. Ankit Deshmukh