knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

dir.create("svg", showWarnings = FALSE)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# install devout and its dependencies
#
# svgpatternsimple - a set of simple patterns in SVG
# devout           - Framework for creating graphics devices in plain R
# devoutsvg        - Custom SVG device
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# devtools::install_github("coolbutuseless/svgpatternsimple") 
# devtools::install_github("coolbutuseless/devout")    
# devtools::install_github("coolbutuseless/devoutsvg") 

suppressPackageStartupMessages({
  library(devout)
  library(devoutsvg)
  library(svgpatternsimple)

  library(dplyr)
  library(tidyr)
  library(ggplot2)
  library(ggridges)
})

Deaths Of Drug Poisoning

This vignette recreates a plot with vertical colour gradient. It was developed by VictimOfMaths and the complete version is available on github.

The image below on the left is from the UK Office for National Statistics (ONS).

The image on the right is created using R, ggplot and devoutsvg

# Simple gradient example Create, view, debug and iterate to find a gradient fill of your liking. wzxhzdk:2 wzxhzdk:3 wzxhzdk:4 # Recreate the ONS Plot * Grab the raw data from the ONS * Reshape into tidy form * Create a `ggridges` plot * Use the `devoutsvg` device with `svgpatternsimple` * Use the encoded gradient created above (i.e. `gradRGB`) as the fill colour for the ridges. wzxhzdk:5

coolbutuseless/devoutsvg documentation built on April 24, 2020, 10:32 a.m.