Browse Source

pokemon!

pull/3/head
boB Rudis 8 years ago
parent
commit
32864ba31e
  1. 5
      NAMESPACE
  2. 1617
      R/a-pokemon-colors.r
  3. 61
      R/pokemon.r
  4. 15
      man/list_avatars.Rd
  5. 15
      man/pokemon_pal.Rd
  6. 30
      man/scale_pokemon.Rd

5
NAMESPACE

@ -17,6 +17,11 @@ export(coord_proj)
export(geom_bkde)
export(geom_bkde2d)
export(geom_xspline)
export(list_avatars)
export(pokemon_pal)
export(scale_color_pokemon)
export(scale_colour_pokemon)
export(scale_fill_pokemon)
export(stat_ash)
export(stat_bkde)
export(stat_bkde2d)

1617
R/a-pokemon-colors.r

File diff suppressed because it is too large

61
R/pokemon.r

@ -0,0 +1,61 @@
#' Pokemon color scales
#'
#' Color scales using the colors in the Pokemon characters
#'
#' Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
#'
#' @inheritParams ggplot2::scale_colour_hue
#' @inheritParams pokemon_pal
#' @family colour pokemon
#' @rdname scale_pokemon
#' @seealso \code{\link{theme_economist}} for examples.
#' @export
scale_colour_pokemon <- function(avatar="bulbasaur", ...) {
discrete_scale("colour", "pokemon", pokemon_pal(avatar=avatar), ...)
}
#' @rdname scale_pokemon
#' @export
scale_color_pokemon <- scale_colour_pokemon
#' @rdname scale_pokemon
#' @export
scale_fill_pokemon <- function(avatar=FALSE, ...) {
discrete_scale("fill", "pokemon", pokemon_pal(avatar=avatar), ...)
}
#' Pick a Pokemon palette
#'
#' Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
#'
#' @param avatar avatar name. Use \code{list_avatars()} to see them all!
#' @export
pokemon_pal <- function(avatar="bulbasaur") {
avatar <- tolower(avatar)
if (!(avatar %in% names(pokemon))) {
message("avatar not found, using 'bulbasaur'")
avatar <- "bulbasaur"
}
best_colors <- function(avatar, n=1) {
unname(pokemon[[avatar]])
}
function(n) {
best_colors(avatar, n)
}
}
#' List Pokemon avatar names
#'
#' Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
#'
#' @note Warning: huge! list
#' @export
list_avatars <- function() {
sort(names(pokemon))
}

15
man/list_avatars.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pokemon.r
\name{list_avatars}
\alias{list_avatars}
\title{List Pokemon avatar names}
\usage{
list_avatars()
}
\description{
Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
}
\note{
Warning: huge! list
}

15
man/pokemon_pal.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pokemon.r
\name{pokemon_pal}
\alias{pokemon_pal}
\title{Pick a Pokemon palette}
\usage{
pokemon_pal(avatar = "bulbasaur")
}
\arguments{
\item{avatar}{avatar name. Use \code{list_avatars()} to see them all!}
}
\description{
Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
}

30
man/scale_pokemon.Rd

@ -0,0 +1,30 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pokemon.r
\name{scale_colour_pokemon}
\alias{scale_color_pokemon}
\alias{scale_colour_pokemon}
\alias{scale_fill_pokemon}
\title{Pokemon color scales}
\usage{
scale_colour_pokemon(avatar = "bulbasaur", ...)
scale_color_pokemon(avatar = "bulbasaur", ...)
scale_fill_pokemon(avatar = FALSE, ...)
}
\arguments{
\item{avatar}{avatar name. Use \code{list_avatars()} to see them all!}
\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
to control name, limits, breaks, labels and so forth.}
}
\description{
Color scales using the colors in the Pokemon characters
}
\details{
Data taken from the hard work by the \href{http://www.pokegraphs.com/}{folks here}.
}
\seealso{
\code{\link{theme_economist}} for examples.
}
Loading…
Cancel
Save