Learn R Programming

rPlotter

A collection of wrapper functions for graphics. The objective of this package is to make plotting easier for R beginners.

Dependencies

This package depends on the following packages:

  • ggplot2 (available on CRAN)
  • stringr (available on CRAN)
  • reshape2 (available on CRAN)
  • dichromat (available on CRAN)
  • picante (available on CRAN)
  • colorspace (available on CRAN)
  • EBImage (available on Bioconductor)
  • rblocks (available on GitHub)

Installation

## CRAN Packages
install.packages(c("ggplot2", "stringr", "reshape2", "dichromat"))

## EBImage
source("http://bioconductor.org/biocLite.R")
biocLite("EBImage")

## Packages on GitHub
library(devtools)
install_github("ramnathv/rblocks")

## And finally ...
install_github("woobe/rPlotter")

Example: extract_colours(...)

This function extracts dominant colours from images and then returns colour hex code.

library(rPlotter)
## Using the R Logo
pal_r <- extract_colours("http://developer.r-project.org/Logo/Rlogo-1.png")
par(mfrow = c(1,2))
pie(rep(1, 5), col = pal_r, main = "Palette based on R Logo")
hist(Nile, breaks = 5, col = pal_r, main = "Palette based on R Logo")

## Using a poster from the movie "Kill Bill"
pal_kb <- extract_colours("http://www.moviegoods.com/Assets/product_images/1010/477803.1010.A.jpg")
par(mfrow = c(1,2))
pie(rep(1, 5), col = pal_kb, main = "Palette based on Kill Bill")
hist(Nile, breaks = 5, col = pal_kb, main = "Palette based on Kill Bill")

## Using Homer Simpson
pal_s <- extract_colours("http://haphappy.com/wp-content/uploads/2011/03/homerbeer2.png")
par(mfrow = c(1,2))
pie(rep(1, 5), col = pal_s, main = "Palette based on Simpsons")
hist(Nile, breaks = 5, col = pal_s, main = "Palette based on Simpsons")

Example: display_colours(...)

This function displays colours as rblocks.

set.seed(1234)
pal_pf <- extract_colours("http://www.scoutlondon.com/blog/wp-content/uploads/2012/05/Pulp-Fiction.jpg")
display_colours(pal_pf)

Example: simulate_colours(...)

The functions simulates three types of colour blindness and then displays the simulated colours as rblocks.

set.seed(1234)
pal_pf <- extract_colours("http://www.scoutlondon.com/blog/wp-content/uploads/2012/05/Pulp-Fiction.jpg")
simulate_colours(pal_pf)

Related Blog Posts

Credits

Copy Link

Version

Version

0.0.8

License

MIT

Maintainer

Jofai Chow

Last Published

February 15th, 2017

Functions in rPlotter (0.0.8)

plot_radar

Create radar (spider) charts from a data frame
extract_colours

Detect and extract dominant colours from an image
display_colours

Display colour using rblocks
simulate_colours

Simulate Three Different Types of Colour Blindness (Deuteranopia, Protanopia & Tritanopia)
create_ggtheme

Create customised themes for ggplot2 object
interpolate_colours

Interpolate colour palette to render more colours within the input range
mpd_select_colours

Select colours from a palette to maximize perceptual distance between the colours
palette_reduce

Reduce palette by removing colours with low saturation, or low or high luminance