No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
examples
images
man
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.md
Rplots.ps
mmviz.Rproj

README.md

Introduction

Standard MassMutual visualization theme built on R ggplot.

Installation

if (!require(devtools)) install.packages("devtools")
devtools:::install_github("massmutual/mmviz")

Example

p <- ggplot(diamonds, aes(price, fill=clarity))
p <- p + geom_histogram(binwidth = 1000)
p <- p + scale_fill_mm(name = "Clarity", type="qual")
p <- p + theme_mm("column")
p <- p + labs(title = "Distribtion of Diamond Price", x = "Price (bin width = 1000)", y = "Density")
p

Available Functions

Theme

  • theme_mm(chart_type: ['bar', 'bar-vertical', 'bar-horizontal', 'freqpoly', 'histogram', 'boxplot', 'boxplot-horizontal', 'jitter', 'polar', 'scatter', 'line', 'hex', 'map'])

Scale

  • scale_fill_mm(name, type: ['qual', 'seq', 'div'])
  • scale_color_mm(name, type: ['qual', 'seq', 'div'])

Utility

  • format_percent(x, digits = 2, format = "f")
  • mmviz_load_fonts()

Setup

Required Libraries

library(ggplot2)
library(extrafont)
library(mmviz)

You will need to install mmviz dependancy packages.

install.packages("ggplot2")
install.packages("extrafont")

R Markdown

Knitr PDF Export

In order to use the mmviz library to style charts in a PDF export you need to install the required font faces. Run the following mmviz utility method to install the required fonts.

mmviz_load_fonts()

Type 'y' when it askes "Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system. Continue? [y/n] "

Finally make sure to include the required libraries in your R markdown file. There are specific examples of R Markdown files that produce PDF output in the examples directory.

Color

Sequential or Diverging Color Palette

You can use the default Sequential or Diverging color palettes by passing type='seq' or type='div'.

p + scale_color_mm(type = "div")
p + scale_fill_mm(type = "seq")

Or you can access each individual Sequential or Diverging color palette by passing type = 'seq_light' or 'seq_dark' or 'div_light' or 'div_dark'

p + scale_color_mm(type = "seq_dark")
p + scale_fill_mm(type = "seq_light")
p + scale_color_mm(type = "div_dark")
p + scale_fill_mm(type = "div_light")

Qualatative Color Palette

You can use the default qualitative color palettes by passing type='qual'.

p + scale_fill_mm(type = "qual")
p + scale_color_mm(type = "qual")

Or you can access each individual qualitative color palettes by passing type = 'qual_light' or 'qual_dark' or 'qual_alt_light' or 'qual_alt_dark'

p + scale_fill_mm(type = "qual_light")
p + scale_color_mm(type = "qual_dark")
p + scale_fill_mm(type = "qual_alt_light")
p + scale_color_mm(type = "qual_alt_dark")