pilot is a general purpose ggplot2 theme with an accessible discrete color palette.
This theme uses "Avenir Next" and "Avenir Next Demi Bold" as the base and title fonts by default. Use the
title_family arguments to
theme_pilot() to use other fonts.
Install from GitHub using devtools.
This theme includes an accessible discrete color palette, comprising six colors that are visually distinct to people with the most commmon types of color blindness.
These colors are available in a named vector called
pilot_colors. You can use these with
scale_manual() in ggplot2 to map specific colors to categorical variables.
The base color names are:
These colors are also avaialable as ggplot2 scales with a range of palettes representing different subsets of the colors (see below). However, care should be taken in how you use these scales. For convenience these scales support ggplot2's color interpolation feature. But expanding the six color palette to represent more than six categories risks creating new colors that are no longer visually distinct to people with color blindness. The sequence of colours in the main palette has been chosen to reduce this risk, but if you want ensure the colors remain distinct you should use these scales with discrete data that has the same number of categories as the palette you choose.
Set the theme for the session with:
library(ggplot2) library(pilot) theme_set(theme_pilot())
Or apply the theme directly to a specific plot with
pilot::theme_pilot(base_family = "Avenir Next", title_family = "Avenir Next Demi Bold", subtitle = TRUE, axes = "", grid = "hv")
Sets the theme with the following arguments:
- base_family The font family name to use for the base font as a string. The default is "Avenir Next".
- title_family The font family name to use for the chart title font as a string. The default is "Avenir Next Demi Bold".
- subtitle Boolean to indicate whether the plot has a subtitle. This argument controls the spacing after the title, so that it is smaller when a subtitle is present. The default is TRUE.
- axes A string to indicate which axes should have axis lines and ticks. Designate the axes to show by including a particular character in the string: "t" for top, "r" for right, "b" for bottom, "l" for left. You will need to position the axes correctly with ggplot, and turn on any secondary axes, in order for the specified axes lines and ticks to be displayed. The default is "", meaning no axes are shown by default.
- grid A string to indicate which gridlines should be shown. Designate which gridlines to show by including a particular character in the string: "h" for horizontal, "v" for vertical. The default is "hv", meaning both gridlines are shown by default.
scale_fill_pilot() as approriate. Both functions have the same signature. Please see the note on colors above for appropiate use of these scales.
pilot::scale_color_pilot(palette = "main", discrete = TRUE, reverse = FALSE, ...)
pilot::scale_fill_pilot(palette = "main", discrete = TRUE, reverse = FALSE, ...)
Sets the scales with the following arguments:
- palette The name of a palette. Valid names are:
- main - The main six color palette
- blues - blue, sky
- greens - green, mint
- blumag - blue, magenta
- dark - blue, green, magenta
- light - sky, mint, yellow
- blugrn - blue, sky, mint, green
- five - blue, sky, mint, yellow, green
- discrete Boolean to indicate if color aesthetic is discrete.
- reverse Boolean to indicate whether palette should be reversed.
- ... Additional arguments passed to
scale_color_gradientn, depending on the value of