knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "figs/README-" )
ggfocus is an extension to ggplot2 that adds scales for emphasizing different features of a plot.
# install.packages("devtools") devtools::install_github("dylan-stark/ggfocus")
Just add a scale_colour_focus()
call to your plots at set the position (pos
) argument to the position in the color scale that you want to emphasize.
The selected position will retain it's color while all other positions will map to gray scale.
Here's an example:
library(ggplot2) library(ggfocus) p3 <- ggplot(economics_long, aes(date, value01, colour = variable)) + geom_line() p3 p3 + scale_colour_focus(3)
Check out the package vignette (vignette("ggfocus")
) for more examples.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.