The goal of dscstyle
is to provide a unified style for the DSC-WAV
project.
You can install the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("DSC-WAV/dscstyle")
The package dscstyle includes three color palettes that are colorblind friendly and look good with the DSC-WAV logo. These palettes are available in the two ggplot2 scale functions:
scale_color_dsc()
scale_fill_dsc()
These scale functions default to a dark color palette
(palette="dark"
). There is also a lighter palette option
(palette="light"
) that can be included in these functions, as well as
a palette for ordered data (palette="blues"
).
Dark Palette
Light Palette
Blues Palette
There is also a ggplot2 theme included in the dscstyle package:
theme_dsc()
This uses the Google font Oswald in to format text. To use this requires
the showtext package. While using theme_dsc()
will render
correctly when knitting to an HTML document, unfortunately, it will not
render in the RStudio viewer.
Additionally, you will need to set the chunk option for your plot to
include fig.showtext=TRUE
.
library(dscstyle)
library(ggplot2)
# Load the Oswald font
sysfonts::font_add_google("Oswald", "Oswald")
ggplot(data = iris, aes(x = Sepal.Length, fill = Species)) +
geom_histogram() +
theme_dsc() +
scale_fill_dsc()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
The dscstyle package also includes a report template to style HTML rendered evaluation reports.
File > New File > R Markdown...
From Template
OK
You may need to install the showtext package prior to the first time you use this template. This allows the Oswald Google font to be used in the plots.
This template sets many global knitr options including
fig.showtext=TRUE
, so that they do not have to be included in each
chunk.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.