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

Commit 12114ec

Browse files
author
Bhaskar Karambelkar
committed
Fixes #3 and switched to pkgdown from staticdoc
1 parent bdfbda2 commit 12114ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1073
-8642
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: colormap
22
Type: Package
33
Title: Color Palettes using Colormaps Node Module
4-
Version: 0.1.3
4+
Version: 0.1.4
55
Authors@R: person("Bhaskar", "Karambelkar", email = "[email protected]",
66
role = c("aut", "cre"))
7-
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.
7+
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'.
88
License: MIT + file LICENSE
99
Encoding: UTF-8
1010
LazyData: true

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# colormap 0.1.4
2+
3+
* Made viridis the default theme.
4+
15
# colormap 0.1.3
26

37
* Fixed all R CMD Check warnings/notes.

R/colormap.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ colormaps <- list(
8989
#'
9090
#' @return Colors either in vector, matrix, list format depending on format.
9191
#' @examples
92-
#' colormap() # Defaults to 72 colors from the 'jet' palette.
92+
#' colormap() # Defaults to 72 colors from the 'viridis' palette.
9393
#' colormap(colormap=colormaps$temperature, nshades=20) # Diff Palette
9494
#' colormap(colormap=c('#000000','#FF0000'), nshades=20) # Colormap as vector of colors
9595
#' # list of list. Maximum flexibility
9696
#' colormap(colormap=list(list(index=0,rgb=c(0,0,0)),list(index=1,rgb=c(255,255,255))), nshades=10)
9797
#' colormap(format='rgb',nshades=10) # As rgb
9898
#' colormap(format='rgb',nshades=10,alpha=0.5) # Constant alpha
9999
#' colormap(format='rgbaString',nshades=10) # As rgba string
100-
colormap <- function(colormap=colormaps$jet, nshades=72,
100+
colormap <- function(colormap=colormaps$viridis, nshades=72,
101101
format='hex', alpha=1, reverse=FALSE) {
102102

103103
# validate inputs
@@ -107,10 +107,10 @@ colormap <- function(colormap=colormaps$jet, nshades=72,
107107
colormap))
108108
} else if(length(colormap)>1 && !(all(grepl('^#[0-9a-f]{6}$',colormap,
109109
ignore.case = T)))) {
110-
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')")
110+
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')")
111111
}
112112
} else if(!inherits(colormap,'list')) {
113-
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)))")
113+
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)))")
114114
}
115115

116116
if(!(is.numeric(alpha) && alpha >=0 && alpha <= 1)) {

R/scales.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' @return A function that can generate colors from a specified colormap.
1515
#'
1616
#' @export
17-
colormap_pal <- function(alpha = 1, colormap = colormaps$jet, reverse=FALSE) {
17+
colormap_pal <- function(alpha = 1, colormap = colormaps$viridis, reverse=FALSE) {
1818
function(n) {
1919
colormap(colormap=colormap, alpha = alpha,
2020
format='hex', reverse=reverse,
@@ -28,7 +28,7 @@ colormap_pal <- function(alpha = 1, colormap = colormaps$jet, reverse=FALSE) {
2828
#' @aliases scale_colour_colormap
2929
#'
3030
#' @export
31-
scale_color_colormap <- function(..., alpha = 1, colormap = colormaps$jet,
31+
scale_color_colormap <- function(..., alpha = 1, colormap = colormaps$viridis,
3232
discrete = FALSE, reverse = FALSE) {
3333

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

7373
if (discrete) {

README-eg1-1.png

-63 Bytes
Loading

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The main function is `colormap` which takes 5 optional arguments
5959
```{r eg1}
6060
library(colormap)
6161
62-
# Defaults to 72 colors from the 'jet' palette.
62+
# Defaults to 72 colors from the 'viridis' palette.
6363
scales::show_col(colormap(), labels = F)
6464
6565
# Specify a different palette from a list of pre-defined palette.

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Example
5252
``` r
5353
library(colormap)
5454

55-
# Defaults to 72 colors from the 'jet' palette.
55+
# Defaults to 72 colors from the 'viridis' palette.
5656
scales::show_col(colormap(), labels = F)
5757
```
5858

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

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

113113
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
211211

212212
``` r
213213
ensureCranPkg('purrr')
214-
#> Installing package into '/opt/user/code/personal/github/colormap/packrat/lib/x86_64-apple-darwin15.6.0/3.3.1'
215-
#> (as 'lib' is unspecified)
216214
par(mfrow=c(44,1))
217215
par(mar=rep(0.25,4))
218216
purrr::walk(colormaps, function(x) {

docs/README-eg1-1.png

-63 Bytes
Loading

docs/README-ggplot2-1.png

134 Bytes
Loading

docs/README-ggplot2-2.png

205 Bytes
Loading

docs/README-maps-1.png

-5.86 KB
Loading

docs/README-maps-2.png

-53.7 KB
Loading

docs/colormap.html

Lines changed: 0 additions & 187 deletions
This file was deleted.

0 commit comments

Comments
 (0)