Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Fixes #3 and switched to pkgdown from staticdoc
Browse files Browse the repository at this point in the history
Bhaskar Karambelkar committed Oct 22, 2016

Unverified

No user is associated with the committer email.
1 parent bdfbda2 commit 12114ec
Showing 43 changed files with 1,073 additions and 8,642 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: colormap
Type: Package
Title: Color Palettes using Colormaps Node Module
Version: 0.1.3
Version: 0.1.4
Authors@R: person("Bhaskar", "Karambelkar", email = "[email protected]",
role = c("aut", "cre"))
Description: This is an R package that allows you to generate colors from color palettes defined in Node.js's colormap (https://github.com/bpostlethwaite/colormap) module. In total it provides 44 distinct palettes made from sequential and/or diverging colors. In addition to the pre defined palettes you can also specify your own set of colors. There are also scale functions that can be used with ggplot2.
Description: Allows to generate colors from palettes defined in the colormap module of 'Node.js'. (see <https://github.com/bpostlethwaite/colormap> for more information). In total it provides 44 distinct palettes made from sequential and/or diverging colors. In addition to the pre defined palettes you can also specify your own set of colors. There are also scale functions that can be used with 'ggplot2'.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# colormap 0.1.4

* Made viridis the default theme.

# colormap 0.1.3

* Fixed all R CMD Check warnings/notes.
8 changes: 4 additions & 4 deletions R/colormap.R
Original file line number Diff line number Diff line change
@@ -89,15 +89,15 @@ colormaps <- list(
#'
#' @return Colors either in vector, matrix, list format depending on format.
#' @examples
#' colormap() # Defaults to 72 colors from the 'jet' palette.
#' colormap() # Defaults to 72 colors from the 'viridis' palette.
#' colormap(colormap=colormaps$temperature, nshades=20) # Diff Palette
#' colormap(colormap=c('#000000','#FF0000'), nshades=20) # Colormap as vector of colors
#' # list of list. Maximum flexibility
#' colormap(colormap=list(list(index=0,rgb=c(0,0,0)),list(index=1,rgb=c(255,255,255))), nshades=10)
#' colormap(format='rgb',nshades=10) # As rgb
#' colormap(format='rgb',nshades=10,alpha=0.5) # Constant alpha
#' colormap(format='rgbaString',nshades=10) # As rgba string
colormap <- function(colormap=colormaps$jet, nshades=72,
colormap <- function(colormap=colormaps$viridis, nshades=72,
format='hex', alpha=1, reverse=FALSE) {

# validate inputs
@@ -107,10 +107,10 @@ colormap <- function(colormap=colormaps$jet, nshades=72,
colormap))
} else if(length(colormap)>1 && !(all(grepl('^#[0-9a-f]{6}$',colormap,
ignore.case = T)))) {
stop("colormap parameter should be a single string from the colormap::colormaps list or a vector of strings in HEX color format\n e.g. colormap='jet' or colormap=c('#FCFDA1','#FF0033')")
stop("colormap parameter should be a single string from the colormap::colormaps list or a vector of strings in HEX color format\n e.g. colormap='viridis' or colormap=c('#FCFDA1','#FF0033')")
}
} else if(!inherits(colormap,'list')) {
stop("colormap parameter should be a single string from the colormap::colormaps list or a vector of strings in HEX color format\n e.g. colormap='jet' or colormap=c('#FCFDA1','#FF0033') or a list of lists e.g. colormap=list(list(index=0,rgb=c(0,0,0)),list(index=1,rgb=c(255,255,255)))")
stop("colormap parameter should be a single string from the colormap::colormaps list or a vector of strings in HEX color format\n e.g. colormap='viridis' or colormap=c('#FCFDA1','#FF0033') or a list of lists e.g. colormap=list(list(index=0,rgb=c(0,0,0)),list(index=1,rgb=c(255,255,255)))")
}

if(!(is.numeric(alpha) && alpha >=0 && alpha <= 1)) {
6 changes: 3 additions & 3 deletions R/scales.R
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
#' @return A function that can generate colors from a specified colormap.
#'
#' @export
colormap_pal <- function(alpha = 1, colormap = colormaps$jet, reverse=FALSE) {
colormap_pal <- function(alpha = 1, colormap = colormaps$viridis, reverse=FALSE) {
function(n) {
colormap(colormap=colormap, alpha = alpha,
format='hex', reverse=reverse,
@@ -28,7 +28,7 @@ colormap_pal <- function(alpha = 1, colormap = colormaps$jet, reverse=FALSE) {
#' @aliases scale_colour_colormap
#'
#' @export
scale_color_colormap <- function(..., alpha = 1, colormap = colormaps$jet,
scale_color_colormap <- function(..., alpha = 1, colormap = colormaps$viridis,
discrete = FALSE, reverse = FALSE) {

if (discrete) {
@@ -67,7 +67,7 @@ scale_color_colormap <- function(..., alpha = 1, colormap = colormaps$jet,
#' @rdname scale_colormap
#'
#' @export
scale_fill_colormap <- function(..., alpha = 1, colormap = colormaps$jet,
scale_fill_colormap <- function(..., alpha = 1, colormap = colormaps$viridis,
discrete = FALSE, reverse = FALSE) {

if (discrete) {
Binary file modified README-eg1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ The main function is `colormap` which takes 5 optional arguments
```{r eg1}
library(colormap)
# Defaults to 72 colors from the 'jet' palette.
# Defaults to 72 colors from the 'viridis' palette.
scales::show_col(colormap(), labels = F)
# Specify a different palette from a list of pre-defined palette.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ Example
``` r
library(colormap)

# Defaults to 72 colors from the 'jet' palette.
# Defaults to 72 colors from the 'viridis' palette.
scales::show_col(colormap(), labels = F)
```

@@ -97,17 +97,17 @@ You can also get the colors in a 'rgb' matrix and a rgba string vector format
``` r
colormap(format='rgb',nshades=5) # As rgb
#> [,1] [,2] [,3] [,4]
#> [1,] 0 0 131 1
#> [2,] 2 156 212 1
#> [3,] 128 255 130 1
#> [4,] 253 130 0 1
#> [5,] 128 0 0 1
#> [1,] 68 1 84 1
#> [2,] 59 81 139 1
#> [3,] 33 144 141 1
#> [4,] 92 200 99 1
#> [5,] 253 231 37 1

colormap(format='rgbaString',nshades=10) # As rgba string
#> [1] "rgba(0,0,131,1)" "rgba(0,54,166,1)" "rgba(2,134,202,1)"
#> [4] "rgba(4,224,242,1)" "rgba(72,255,186,1)" "rgba(188,255,69,1)"
#> [7] "rgba(254,215,0,1)" "rgba(252,97,0,1)" "rgba(238,0,0,1)"
#> [10] "rgba(128,0,0,1)"
#> [1] "rgba(68,1,84,1)" "rgba(71,39,117,1)" "rgba(62,72,135,1)"
#> [4] "rgba(49,102,141,1)" "rgba(38,130,141,1)" "rgba(36,157,136,1)"
#> [7] "rgba(55,181,120,1)" "rgba(109,204,88,1)" "rgba(176,221,49,1)"
#> [10] "rgba(253,231,37,1)"
```

You also get `scale_fill_colormap` and `scale_color_colormap` functions for using these palettes in ggplot2 plots. Check `?colormap::scale_fill_colormap` for details.
@@ -211,8 +211,6 @@ Here is a plot showing all 44 pre-defined color palettes and the colors they gen

``` r
ensureCranPkg('purrr')
#> Installing package into '/opt/user/code/personal/github/colormap/packrat/lib/x86_64-apple-darwin15.6.0/3.3.1'
#> (as 'lib' is unspecified)
par(mfrow=c(44,1))
par(mar=rep(0.25,4))
purrr::walk(colormaps, function(x) {
Binary file modified docs/README-eg1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/README-ggplot2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/README-ggplot2-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/README-maps-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/README-maps-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
187 changes: 0 additions & 187 deletions docs/colormap.html

This file was deleted.

112 changes: 0 additions & 112 deletions docs/colormap_pal.html

This file was deleted.

93 changes: 0 additions & 93 deletions docs/colormaps.html

This file was deleted.

815 changes: 0 additions & 815 deletions docs/css/bootstrap-responsive.css

This file was deleted.

9 changes: 0 additions & 9 deletions docs/css/bootstrap-responsive.min.css

This file was deleted.

4,983 changes: 0 additions & 4,983 deletions docs/css/bootstrap.css

This file was deleted.

9 changes: 0 additions & 9 deletions docs/css/bootstrap.min.css

This file was deleted.

28 changes: 0 additions & 28 deletions docs/css/highlight.css

This file was deleted.

25 changes: 0 additions & 25 deletions docs/css/staticdocs.css

This file was deleted.

93 changes: 0 additions & 93 deletions docs/ct.html

This file was deleted.

Binary file removed docs/img/glyphicons-halflings-white.png
Binary file not shown.
Binary file removed docs/img/glyphicons-halflings.png
Binary file not shown.
439 changes: 209 additions & 230 deletions docs/index.html

Large diffs are not rendered by default.

1,825 changes: 0 additions & 1,825 deletions docs/js/bootstrap.js

This file was deleted.

6 changes: 0 additions & 6 deletions docs/js/bootstrap.min.js

This file was deleted.

123 changes: 123 additions & 0 deletions docs/news/index.html
59 changes: 59 additions & 0 deletions docs/pkgdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
body {
position: relative;
}

.icon img {
float: right;
border: 1px solid #ccc;
}
.index .internal {display: none;}
ul.index li {margin-bottom: 0.5em; clear: both;}

footer {
margin-top: 45px;
padding: 35px 0 36px;
border-top: 1px solid #e5e5e5;
}
footer p {
margin-bottom: 0;
color: #555;
}

/* Fixes for fixed navbar --------------------------*/

body {
position: relative;
padding-top: 60px;
}

.section h1, .section h2, .section h3, .section h4 {
padding-top: 60px;
margin-top: -60px;
}

/* Table of contents --------------------------*/

#tocnav h2 {
margin-top: 0;
font-size: 1.5em;
}


/* Syntax highlighting ---------------------------------------------------- */

.fl,.number {color:rgb(21,20,181);}
.fu,.functioncall {color:#264D66 ;}
.ch,.st,.string {color:#375D81 ;}
.kw,.keyword {font-weight:bolder ;color:black;}
.argument {color:#264D66 ;}
.co,.comment {color: #333;}
.formalargs {color: #264D66;}
.eqformalargs {color:#264D66;}
.slot {font-style:italic;}
.symbol {color:black ;}
.prompt {color:black ;}

pre img {
background-color: #fff;
display: block;
}
13 changes: 13 additions & 0 deletions docs/pkgdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(function() {

$('#tocnav').affix({
offset: {
top: $('#tocnav').offset().top - 80
}
});
$('body').scrollspy({
target: '#tocnav',
offset: 80
});

});
83 changes: 0 additions & 83 deletions docs/reference.html

This file was deleted.

185 changes: 185 additions & 0 deletions docs/reference/colormap.html
Binary file added docs/reference/colormap_pal-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/colormap_pal-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions docs/reference/colormap_pal.html
104 changes: 104 additions & 0 deletions docs/reference/colormaps.html
106 changes: 106 additions & 0 deletions docs/reference/index.html
126 changes: 126 additions & 0 deletions docs/reference/scale_colormap.html
116 changes: 0 additions & 116 deletions docs/scale_colormap.html

This file was deleted.

4 changes: 2 additions & 2 deletions man/colormap.Rd
2 changes: 1 addition & 1 deletion man/colormap_pal.Rd
4 changes: 2 additions & 2 deletions man/scale_colormap.Rd
2 changes: 1 addition & 1 deletion packrat/packrat.opts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use.cache: FALSE
print.banner.on.startup: auto
vcs.ignore.lib: TRUE
vcs.ignore.src: TRUE
external.packages:
external.packages: pkgdown
local.repos:
load.external.packages.on.startup: TRUE
ignored.packages:

0 comments on commit 12114ec

Please sign in to comment.