├── .gitignore ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── R └── werpals.R ├── README.Rmd ├── README.md ├── man ├── disney_colours.Rd ├── disney_cols.Rd ├── disney_pal.Rd ├── disney_palettes.Rd ├── figures │ ├── README-unnamed-chunk-5-1.png │ ├── README-unnamed-chunk-6-1.png │ ├── alice.PNG │ ├── apply.gif │ ├── cinderella.png │ ├── cinderella_blog.PNG │ ├── ggplot_cinderella.png │ ├── ggplot_provence.png │ ├── ggplot_uyuni.png │ ├── help1.gif │ ├── provence.png │ ├── provence_blog.PNG │ ├── uyuni.png │ └── uyuni_blog.PNG ├── nature_colours.Rd ├── nature_cols.Rd ├── nature_pal.Rd ├── nature_palettes.Rd ├── scale_color_disney.Rd ├── scale_color_nature.Rd ├── scale_colour_disney.Rd ├── scale_colour_nature.Rd ├── scale_fill_disney.Rd ├── scale_fill_nature.Rd └── werpals_display.Rd └── werpals.Rproj /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | .Rbuildignore 6 | jhb.PNG 7 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: werpals 2 | Type: Package 3 | Title: Palettes for disney and natural colours from a few blog posts 4 | Version: 0.1.0 5 | Authors@R: c( 6 | person("Vebash", "Naidoo", role = c("aut", "cre"), email = "sciencificity@gmail.com"), 7 | person("Jonathan", "Kitt", role = c("ctb"), email = "biorandomics@gmail.com")) 8 | Description: Palette Colours from: http://elijahmeeks.com/#content/blog/2015_08_17_palettes as well as 9 | https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e 10 | Palette made ffg blog post: https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2. 11 | The palettes and scale functions are built on ggplot2 functions and hence relies on ggplot2 being installed. 12 | License: MIT + file LICENSE 13 | Encoding: UTF-8 14 | LazyData: true 15 | Depends: 16 | R (>= 3.2) 17 | Imports: ggplot2, stringr, graphics, grDevices 18 | RoxygenNote: 6.1.1 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Vebash Naidoo 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Vebash Naidoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(disney_palettes) 4 | export(nature_palettes) 5 | export(scale_color_disney) 6 | export(scale_color_nature) 7 | export(scale_colour_disney) 8 | export(scale_colour_nature) 9 | export(scale_fill_disney) 10 | export(scale_fill_nature) 11 | export(werpals_display) 12 | importFrom("grDevices","colorRampPalette") 13 | importFrom("stringr","str_glue") 14 | importFrom(ggplot2,discrete_scale) 15 | importFrom(ggplot2,scale_color_gradientn) 16 | importFrom(ggplot2,scale_colour_gradientn) 17 | importFrom(ggplot2,scale_fill_gradientn) 18 | importFrom(graphics,image) 19 | importFrom(graphics,par) 20 | importFrom(graphics,plot) 21 | importFrom(graphics,rect) 22 | importFrom(graphics,text) 23 | -------------------------------------------------------------------------------- /R/werpals.R: -------------------------------------------------------------------------------- 1 | 2 | # Palette Colours from : 3 | # http://elijahmeeks.com/#content/blog/2015_08_17_palettes 4 | # Palette made ffg blog post: 5 | # https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 6 | 7 | # Nature colours from: 8 | # https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e 9 | 10 | # if (base::getRversion() >= "2.15.1") { 11 | # utils::globalVariables(c("col.number", "nc", "nj", "nr")) 12 | # } 13 | 14 | #' The list of disney colours 15 | disney_colours <- c( 16 | `cind1` = "#96abb1", 17 | `cind2` = "#313746", 18 | `cind3` = "#b0909d", 19 | `cind4` = "#687a97", 20 | `cind5` = "#292014", 21 | `monet1` = "#08221c", 22 | `monet2` = "#113719", 23 | `monet3` = "#36611b", 24 | `monet4` = "#72972f", 25 | `monet5` = "#a4b77d", 26 | `monet6` = "#cdc597", 27 | `smallworld1` = "#00a2ce", 28 | `smallworld2` = "#b3331d", 29 | `smallworld3` = "#b6a756", 30 | `smallworld4` = "#122753", 31 | `smallworld5` = "#b86117", 32 | `smallworld6` = "#4d430c", 33 | `alice1` = "#827abf", 34 | `alice2` = "#f62150", 35 | `alice3` = "#6f89b6", 36 | `alice4` = "#f5e0b7", 37 | `alice5` = "#5b1e37", 38 | `alice6` = "#b9e3c5", 39 | `pan1` = "#27552d", 40 | `pan2` = "#e46538", 41 | `pan3` = "#96bb77", 42 | `pan4` = "#e5e36e", 43 | `pan5` = "#e6a19f", 44 | `pan6` = "#159eb7", 45 | `yourage1` = "#3b4274", 46 | `yourage2` = "#d2130a", 47 | `yourage3` = "#c8a88a", 48 | `yourage4` = "#857d7b", 49 | `yourage5` = "#592e2a", 50 | `yourage6` = "#e39587", 51 | # For Firefly 52 | `firefly1` = "#866748", 53 | `firefly2` = "#5d3426", 54 | `firefly3` = "#bea58a", 55 | `firefly4` = "#964536", 56 | `firefly5` = "#85624f", 57 | `firefly6` = "#d9bba2", 58 | `firefly7` = "#8c3e27", 59 | `firefly8` = "#874e45", 60 | `firefly9` = "#9e4730", 61 | `firefly10` = "#3e211a" 62 | ) 63 | 64 | #' The list of nature colours 65 | nature_colours <- c( 66 | # For the Uyuni Salt Flats (Bolivia) 67 | `uyuni1` = "#fecda5", 68 | `uyuni2` = "#ffb281", 69 | `uyuni3` = "#ff9175", 70 | `uyuni4` = "#bc8a96", 71 | `uyuni5` = "#606594", 72 | `uyuni6` = "#352436", 73 | `uyuni7` = "#09040a", 74 | `uyuni8` = "#01609f", 75 | `uyuni9` = "#53c1e2", 76 | `uyuni10` = "#d2c4c4", 77 | # For the Okavango Delta (Botswana) 78 | `okavango1` = "#f7edca", 79 | `okavango2` = "#f5dc9a", 80 | `okavango3` = "#8eb155", 81 | `okavango4` = "#497367", 82 | `okavango5` = "#2b3f00", 83 | `okavango6` = "#764000", 84 | `okavango7` = "#e19e57", 85 | `okavango8` = "#020570", 86 | `okavango9` = "#3165b1", 87 | `okavango10` = "#b8f7fe", 88 | # For Lake Louise (Canada) 89 | `lakelouise1` = "#f6fcfc", 90 | `lakelouise2` = "#81c7e0", 91 | `lakelouise3` = "#00b8de", 92 | `lakelouise4` = "#007c94", 93 | `lakelouise5` = "#617ca9", 94 | `lakelouise6` = "#003478", 95 | `lakelouise7` = "#00c0c3", 96 | `lakelouise8` = "#017e5c", 97 | `lakelouise9` = "#71c100", 98 | `lakelouise10` = "#f3d100", 99 | # For Provence (France) 100 | `provence1` = "#def7fb", 101 | `provence2` = "#00d0fe", 102 | `provence3` = "#00a0de", 103 | `provence4` = "#2b161d", 104 | `provence5` = "#5f2c57", 105 | `provence6` = "#ca5cbb", 106 | `provence7` = "#ff71bd", 107 | `provence8` = "#b79289", 108 | `provence9` = "#fec4b9", 109 | `provence10` = "#fdebd2", 110 | # For Halong Bay (Vietnam) 111 | `halong1` = "#fee871", 112 | `halong2` = "#ffd960", 113 | `halong3` = "#ffa74d", 114 | `halong4` = "#fe6927", 115 | `halong5` = "#cb5201", 116 | `halong6` = "#7b2d00", 117 | `halong7` = "#430301", 118 | `halong8` = "#b37400", 119 | `halong9` = "#987c00", 120 | `halong10` = "#3f4903", 121 | # For Vatnajokull (Iceland) 122 | `vatnajokull1` = "#fefefe", 123 | `vatnajokull2` = "#d7e8f8", 124 | `vatnajokull3` = "#9ac5e8", 125 | `vatnajokull4` = "#00f7ff", 126 | `vatnajokull5` = "#00c6ff", 127 | `vatnajokull6` = "#0090ff", 128 | `vatnajokull7` = "#0142fe", 129 | `vatnajokull8` = "#002969", 130 | `vatnajokull9` = "#566199", 131 | `vatnajokull10` = "#b7baf3", 132 | # For Arashiyama (Japan) 133 | `arashiyama1` = "#fdfdfd", 134 | `arashiyama2` = "#e9ed00", 135 | `arashiyama3` = "#67bd02", 136 | `arashiyama4` = "#018305", 137 | `arashiyama5` = "#01ac86", 138 | `arashiyama6` = "#003813", 139 | `arashiyama7` = "#110101", 140 | `arashiyama8` = "#b8522c", 141 | `arashiyama9` = "#ff9400", 142 | `arashiyama10` = "#dbd0cc", 143 | # For Mount Cook (New Zealand) 144 | `mountcook1` = "#fefbe8", 145 | `mountcook2` = "#dfdebf", 146 | `mountcook3` = "#aecebf", 147 | `mountcook4` = "#90b7b4", 148 | `mountcook5` = "#30a0a4", 149 | `mountcook6` = "#017987", 150 | `mountcook7` = "#332d15", 151 | `mountcook8` = "#866e52", 152 | `mountcook9` = "#d9b28b", 153 | `mountcook10` = "#ffeed8", 154 | # For Benagil Cave (Portugal) 155 | `benagil1` = "#f5f5e9", 156 | `benagil2` = "#b6cbdc", 157 | `benagil3` = "#8ba2b4", 158 | `benagil4` = "#3a749c", 159 | `benagil5` = "#00517c", 160 | `benagil6` = "#030710", 161 | `benagil7` = "#500a02", 162 | `benagil8` = "#c05100", 163 | `benagil9` = "#fba23c", 164 | `benagil10` = "#ffed77", 165 | # For Bryce Canyon (United States) 166 | `bryce1` = "#9ad1eb", 167 | `bryce2` = "#0097d6", 168 | `bryce3` = "#a79998", 169 | `bryce4` = "#032129", 170 | `bryce5` = "#b98f00", 171 | `bryce6` = "#883f39", 172 | `bryce7` = "#ff692c", 173 | `bryce8` = "#ffc78e", 174 | `bryce9` = "#f5ceaf", 175 | `bryce10` = "#f6f5f1", 176 | # For Jozi skyline - https://lonehillart.com/2017/12/18/penelope-hunter-johannesburg-skyline-900-x-760/ 177 | `jozi1` = "#d1b88b", 178 | `jozi2` = "#ecd8a1", 179 | `jozi3` = "#e4cc79", 180 | `jozi4` = "#ddb400", 181 | `jozi5` = "#d57b4b", 182 | `jozi6` = "#aa4812", 183 | `jozi7` = "#588176", 184 | `jozi8` = "#abb5b4", 185 | `jozi9` = "#6290a4", 186 | `jozi10` = "#193146" 187 | ) 188 | 189 | 190 | #' Function to extract colours as hex codes 191 | #' 192 | #' @param ... Character names of disney_colours 193 | #' 194 | disney_cols <- function(...) { 195 | cols <- c(...) 196 | 197 | if (is.null(cols)) { 198 | return(disney_colours) 199 | } 200 | 201 | disney_colours[cols] 202 | } 203 | 204 | #' Function to extract colours as hex codes 205 | #' 206 | #' @param ... Character names of nature_colours 207 | #' 208 | nature_cols <- function(...) { 209 | cols <- c(...) 210 | 211 | if (is.null(cols)) { 212 | return(nature_colours) 213 | } 214 | 215 | nature_colours[cols] 216 | } 217 | 218 | #' Function to create palettes 219 | #' @export 220 | disney_palettes <- list( 221 | `main` = disney_cols(), 222 | 223 | `cinderella` = disney_cols( 224 | "cind1", "cind2", "cind3", 225 | "cind4", "cind5" 226 | ), 227 | 228 | `monet` = disney_cols( 229 | "monet1", "monet2", "monet3", 230 | "monet4", "monet5", "monet6" 231 | ), 232 | 233 | `small_world` = disney_cols( 234 | "smallworld1", "smallworld2", 235 | "smallworld3", "smallworld4", 236 | "smallworld5", "smallworld6" 237 | ), 238 | 239 | `alice` = disney_cols( 240 | "alice1", "alice2", 241 | "alice3", "alice4", 242 | "alice5", "alice6" 243 | ), 244 | 245 | `pan` = disney_cols( 246 | "pan1", "pan2", 247 | "pan3", "pan4", 248 | "pan5", "pan6" 249 | ), 250 | 251 | `when_i_was_your_age` = disney_cols( 252 | "yourage1", "yourage2", 253 | "yourage3", "yourage4", 254 | "yourage5", "yourage6" 255 | ), 256 | 257 | `firefly` = disney_cols( 258 | # "firefly1", 259 | "firefly2", 260 | "firefly3", "firefly4", 261 | "firefly5", "firefly6", 262 | #"firefly7", 263 | "firefly8", 264 | # "firefly9", 265 | "firefly10" 266 | ) 267 | ) 268 | 269 | #' Function to create palettes 270 | #' @export 271 | nature_palettes <- list( 272 | `main` = nature_cols(), 273 | 274 | `uyuni` = nature_cols( 275 | "uyuni1", "uyuni2", 276 | "uyuni3", "uyuni4", 277 | "uyuni5", "uyuni6", 278 | "uyuni7", "uyuni8", 279 | "uyuni9", "uyuni10" 280 | ), 281 | 282 | `okavango` = nature_cols( 283 | "okavango1", "okavango2", 284 | "okavango3", "okavango4", 285 | "okavango5", "okavango6", 286 | "okavango7", "okavango8", 287 | "okavango9", "okavango10" 288 | ), 289 | 290 | `lakelouise` = nature_cols( 291 | "lakelouise1", "lakelouise2", 292 | "lakelouise3", "lakelouise4", 293 | "lakelouise5", "lakelouise6", 294 | "lakelouise7", "lakelouise8", 295 | "lakelouise9", "lakelouise10" 296 | ), 297 | 298 | `provence` = nature_cols( 299 | "provence1", "provence2", 300 | "provence3", "provence4", 301 | "provence5", "provence6", 302 | "provence7", "provence8", 303 | "provence9", "provence10" 304 | ), 305 | 306 | `halong` = nature_cols( 307 | "halong1", "halong2", 308 | "halong3", "halong4", 309 | "halong5", "halong6", 310 | "halong7", "halong8", 311 | "halong9", "halong10" 312 | ), 313 | 314 | `vatnajokull` = nature_cols( 315 | "vatnajokull1", "vatnajokull2", 316 | "vatnajokull3", "vatnajokull4", 317 | "vatnajokull5", "vatnajokull6", 318 | "vatnajokull7", "vatnajokull8", 319 | "vatnajokull9", "vatnajokull10" 320 | ), 321 | 322 | `arashiyama` = nature_cols( 323 | "arashiyama1", "arashiyama2", 324 | "arashiyama3", "arashiyama4", 325 | "arashiyama5", "arashiyama6", 326 | "arashiyama7", "arashiyama8", 327 | "arashiyama9", "arashiyama10" 328 | ), 329 | 330 | `mountcook` = nature_cols( 331 | "mountcook1", "mountcook2", 332 | "mountcook3", "mountcook4", 333 | "mountcook5", "mountcook6", 334 | "mountcook7", "mountcook8", 335 | "mountcook9", "mountcook10" 336 | ), 337 | 338 | `benagil` = nature_cols( 339 | "benagil1", "benagil2", 340 | "benagil3", "benagil4", 341 | "benagil5", "benagil6", 342 | "benagil7", "benagil8", 343 | "benagil9", "benagil10" 344 | ), 345 | 346 | `bryce` = nature_cols( 347 | "bryce1", "bryce2", 348 | "bryce3", "bryce4", 349 | "bryce5", "bryce6", 350 | "bryce7", "bryce8", 351 | "bryce9", "bryce10" 352 | ), 353 | 354 | `jozi` = nature_cols( 355 | "jozi1", "jozi2", 356 | "jozi3", "jozi4", 357 | "jozi5", "jozi6", 358 | "jozi7", "jozi8", 359 | "jozi9", "jozi10" 360 | ) 361 | ) 362 | 363 | 364 | #' Return function to interpolate a disney colour palette 365 | #' 366 | #' @importFrom "grDevices" "colorRampPalette" 367 | #' @importFrom "stringr" "str_glue" 368 | #' @param palette Character name of palette in disney_palettes 369 | #' @param reverse Boolean indicating whether the palette should be reversed 370 | #' @param ... Additional arguments to pass to colorRampPalette() 371 | #' 372 | disney_pal <- function(palette = "main", reverse = FALSE, ...) { 373 | pal <- disney_palettes[[palette]] 374 | 375 | if (is.null(pal)) { 376 | stop(stringr::str_glue("Cannot find palette! Palette names are: cinderella, monet, small_world, alice, 377 | pan, when_i_was_your_age, firefly, main.")) 378 | } 379 | 380 | if (reverse) pal <- rev(pal) 381 | 382 | grDevices::colorRampPalette(pal, ...) 383 | } 384 | 385 | 386 | #' Return function to interpolate a nature colour palette 387 | #' 388 | #' @importFrom "grDevices" "colorRampPalette" 389 | #' @importFrom "stringr" "str_glue" 390 | #' @param palette Character name of palette in nature_palettes 391 | #' @param reverse Boolean indicating whether the palette should be reversed 392 | #' @param ... Additional arguments to pass to colorRampPalette() 393 | #' 394 | nature_pal <- function(palette = "main", reverse = FALSE, ...) { 395 | pal <- nature_palettes[[palette]] 396 | 397 | if (is.null(pal)) { 398 | stop(stringr::str_glue("Cannot find palette! Palette names are: uyuni, okavango, lakelouise, provence, 399 | halong, vatnajokull, arashiyama, mountcook, benagil, bryce, jozi.")) 400 | } 401 | 402 | if (reverse) pal <- rev(pal) 403 | 404 | grDevices::colorRampPalette(pal, ...) 405 | } 406 | 407 | #' Colour scale constructor for some disney-ish colours 408 | #' 409 | #' This is the default colour scale for categorical variables for the disney-like palette. 410 | #' It does not generate colour-blind safe palettes. 411 | #' These are the palettes to choose from: 412 | #' \itemize{ 413 | #' \item \code{cinderella} 414 | #' \item \code{monet} 415 | #' \item \code{small_world} 416 | #' \item \code{alice} 417 | #' \item \code{pan} 418 | #' \item \code{when_i_was_your_age} 419 | #' \item \code{firefly} 420 | #' \item \code{main} 421 | #' } \cr 422 | #' Palette Colours inspired by: \cr 423 | #' http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 424 | #' Palette made ffg blog post: \cr 425 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 426 | #' 427 | #' @param palette Character name of palette in disney_palettes 428 | #' @param discrete Boolean indicating whether colour aesthetic is discrete or not 429 | #' @param reverse Boolean indicating whether the palette should be reversed 430 | #' @param ... Additional arguments passed to discrete_scale() or 431 | #' scale_color_gradientn(), used respectively when discrete is TRUE or FALSE 432 | #' 433 | #' @return Colour scale of disney-like palette 434 | #' @importFrom ggplot2 discrete_scale scale_colour_gradientn 435 | #' @examples 436 | #' # Colour using the small_world palette 437 | #' library(ggplot2) 438 | #' ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 439 | #' geom_point(size = 4, alpha = .8) + 440 | #' scale_colour_disney( 441 | #' discrete = FALSE, 442 | #' palette = "small_world", 443 | #' guide = "none" 444 | #' ) + 445 | #' facet_wrap(~cyl) 446 | #' 447 | #' # Colour using the `alice` palette, and where cyl is discrete 448 | #' library(ggplot2) 449 | #' ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 450 | #' geom_point(size = 4, alpha = .8) + 451 | #' scale_colour_disney( 452 | #' discrete = TRUE, 453 | #' palette = "alice", 454 | #' guide = "none" 455 | #' ) + 456 | #' facet_wrap(~cyl) 457 | #' @export 458 | scale_colour_disney <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 459 | pal <- disney_pal(palette = palette, reverse = reverse) 460 | 461 | if (discrete) { 462 | ggplot2::discrete_scale("colour", paste0("disney_", palette), palette = pal, ...) 463 | } else { 464 | ggplot2::scale_colour_gradientn(colours = pal(256), ...) 465 | } 466 | } 467 | 468 | #' Color scale constructor for some disney-ish colors 469 | #' 470 | #' This is the default colour scale for categorical variables for the disney-like palette. 471 | #' It does not generate colour-blind safe palettes. 472 | #' These are the palettes to choose from: 473 | #' \itemize{ 474 | #' \item \code{cinderella} 475 | #' \item \code{monet} 476 | #' \item \code{small_world} 477 | #' \item \code{alice} 478 | #' \item \code{pan} 479 | #' \item \code{when_i_was_your_age} 480 | #' \item \code{firefly} 481 | #' \item \code{main} 482 | #' } \cr 483 | #' Palette Colours inspired by: \cr 484 | #' http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 485 | #' Palette made ffg blog post: \cr 486 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 487 | #' 488 | #' @param palette Character name of palette in disney_palettes 489 | #' @param discrete Boolean indicating whether color aesthetic is discrete or not 490 | #' @param reverse Boolean indicating whether the palette should be reversed 491 | #' @param ... Additional arguments passed to discrete_scale() or 492 | #' scale_color_gradientn(), used respectively when discrete is TRUE or FALSE 493 | #' 494 | #' @return Colour scale of disney-like palette 495 | #' @importFrom ggplot2 discrete_scale scale_colour_gradientn 496 | #' @examples 497 | #' # Color by discrete variable using default palette 498 | #' library(ggplot2) 499 | #' ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + 500 | #' geom_point(size = 4) + 501 | #' scale_color_disney() 502 | #' @export 503 | scale_color_disney <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 504 | pal <- disney_pal(palette = palette, reverse = reverse) 505 | 506 | if (discrete) { 507 | ggplot2::discrete_scale("colour", paste0("disney_", palette), palette = pal, ...) 508 | } else { 509 | ggplot2::scale_color_gradientn(colours = pal(256), ...) 510 | } 511 | } 512 | 513 | #' Fill scale constructor for some disney-ish colours 514 | #' 515 | #' This is the default fill scale for the disney-like palette. 516 | #' It does not generate colour-blind safe palettes. 517 | #' These are the palettes to choose from: 518 | #' \itemize{ 519 | #' \item \code{cinderella} 520 | #' \item \code{monet} 521 | #' \item \code{small_world} 522 | #' \item \code{alice} 523 | #' \item \code{pan} 524 | #' \item \code{when_i_was_your_age} 525 | #' \item \code{firefly} 526 | #' \item \code{main} 527 | #' } \cr 528 | #' Palette Colours inspired by: \cr 529 | #' http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 530 | #' Palette made ffg blog post: \cr 531 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 532 | #' 533 | #' @param palette Character name of palette in disney_palettes 534 | #' @param discrete Boolean indicating whether colour aesthetic is discrete or not 535 | #' @param reverse Boolean indicating whether the palette should be reversed 536 | #' @param ... Additional arguments passed to discrete_scale() or 537 | #' scale_fill_gradientn(), used respectively when discrete is TRUE or FALSE 538 | #' 539 | #' @return Fill scale of disney-like palette 540 | #' @importFrom ggplot2 discrete_scale scale_fill_gradientn 541 | #' @examples 542 | #' # Fill by discrete variable with different palette + remove legend (guide) 543 | #' library(ggplot2) 544 | #' ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 545 | #' geom_bar() + 546 | #' theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 547 | #' scale_fill_disney(palette = "main", guide = "none") 548 | #' @export 549 | scale_fill_disney <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 550 | pal <- disney_pal(palette = palette, reverse = reverse) 551 | 552 | if (discrete) { 553 | ggplot2::discrete_scale("fill", paste0("disney_", palette), palette = pal, ...) 554 | } else { 555 | ggplot2::scale_fill_gradientn(colours = pal(256), ...) 556 | } 557 | } 558 | 559 | #' Colour scale constructor for some nature colours 560 | #' 561 | #' This is the default colour scale for categorical variables for the nature palette. 562 | #' It does not generate colour-blind safe palettes. 563 | #' These are the palettes to choose from: 564 | #' \itemize{ 565 | #' \item \code{uyuni} 566 | #' \item \code{okavango} 567 | #' \item \code{lakelouise} 568 | #' \item \code{provence} 569 | #' \item \code{halong} 570 | #' \item \code{vatnajokull} 571 | #' \item \code{arashiyama} 572 | #' \item \code{mountcook} 573 | #' \item \code{benagil} 574 | #' \item \code{bryce} 575 | #' \item \code{jozi} 576 | #' \item \code{main} 577 | #' } \cr 578 | #' Palette Colours inspired by: \cr 579 | #' https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 580 | #' Palette made ffg blog post: \cr 581 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 582 | #' 583 | #' @param palette Character name of palette in nature_palettes 584 | #' @param discrete Boolean indicating whether colour aesthetic is discrete or not 585 | #' @param reverse Boolean indicating whether the palette should be reversed 586 | #' @param ... Additional arguments passed to discrete_scale() or 587 | #' scale_color_gradientn(), used respectively when discrete is TRUE or FALSE 588 | #' 589 | #' @return Colour scale of natural palette 590 | #' @importFrom ggplot2 discrete_scale scale_colour_gradientn 591 | #' @examples 592 | #' # Colour using the `okavango` palette 593 | #' library(ggplot2) 594 | #' ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 595 | #' geom_point(size = 4, alpha = .8) + 596 | #' scale_colour_nature( 597 | #' discrete = FALSE, 598 | #' palette = "uyuni", 599 | #' guide = "none" 600 | #' ) + 601 | #' facet_wrap(~cyl) + 602 | #' theme_dark() 603 | #' 604 | #' # Colour using the `halong` palette, and where cyl is discrete 605 | #' library(ggplot2) 606 | #' ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 607 | #' geom_point(size = 4, alpha = .8) + 608 | #' scale_colour_nature( 609 | #' discrete = TRUE, 610 | #' palette = "halong", 611 | #' guide = "none" 612 | #' ) + 613 | #' facet_wrap(~cyl) 614 | #' @export 615 | scale_colour_nature <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 616 | pal <- nature_pal(palette = palette, reverse = reverse) 617 | 618 | if (discrete) { 619 | ggplot2::discrete_scale("colour", paste0("nature_", palette), palette = pal, ...) 620 | } else { 621 | ggplot2::scale_colour_gradientn(colours = pal(256), ...) 622 | } 623 | } 624 | 625 | 626 | #' Color scale constructor for some nature colors 627 | #' 628 | #' This is the default color scale for categorical variables for the nature palette. 629 | #' It does not generate color-blind safe palettes. 630 | #' These are the palettes to choose from: 631 | #' \itemize{ 632 | #' \item \code{uyuni} 633 | #' \item \code{okavango} 634 | #' \item \code{lakelouise} 635 | #' \item \code{provence} 636 | #' \item \code{halong} 637 | #' \item \code{vatnajokull} 638 | #' \item \code{arashiyama} 639 | #' \item \code{mountcook} 640 | #' \item \code{benagil} 641 | #' \item \code{bryce} 642 | #' \item \code{jozi} 643 | #' \item \code{main} 644 | #' } \cr 645 | #' Palette Colors inspired by: \cr 646 | #' https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 647 | #' Palette made ffg blog post: \cr 648 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 649 | #' 650 | #' @param palette Character name of palette in nature_palettes 651 | #' @param discrete Boolean indicating whether color aesthetic is discrete or not 652 | #' @param reverse Boolean indicating whether the palette should be reversed 653 | #' @param ... Additional arguments passed to discrete_scale() or 654 | #' scale_color_gradientn(), used respectively when discrete is TRUE or FALSE 655 | #' 656 | #' @return Color scale of natural palette 657 | #' @importFrom ggplot2 discrete_scale scale_color_gradientn 658 | #' @examples 659 | #' # Color using the `lakelouise` palette 660 | #' library(ggplot2) 661 | #' ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 662 | #' geom_point(size = 4, alpha = .8) + 663 | #' scale_color_nature( 664 | #' discrete = FALSE, 665 | #' palette = "lakelouise", 666 | #' guide = "none" 667 | #' ) + 668 | #' facet_wrap(~cyl) + 669 | #' theme_dark() 670 | #' 671 | #' # Colour using the `jozi` palette, and where cyl is discrete 672 | #' library(ggplot2) 673 | #' ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 674 | #' geom_point(size = 4, alpha = .8) + 675 | #' scale_color_nature( 676 | #' discrete = TRUE, 677 | #' palette = "jozi", 678 | #' guide = "none" 679 | #' ) + 680 | #' facet_wrap(~cyl) 681 | #' @export 682 | scale_color_nature <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 683 | pal <- nature_pal(palette = palette, reverse = reverse) 684 | 685 | if (discrete) { 686 | ggplot2::discrete_scale("colour", paste0("nature_", palette), palette = pal, ...) 687 | } else { 688 | ggplot2::scale_color_gradientn(colours = pal(256), ...) 689 | } 690 | } 691 | 692 | #' Fill scale constructor for some nature colours 693 | #' 694 | #' This is the default fill scale for the nature palette. 695 | #' It does not generate colour-blind safe palettes. 696 | #' These are the palettes to choose from: 697 | #' \itemize{ 698 | #' \item \code{uyuni} 699 | #' \item \code{okavango} 700 | #' \item \code{lakelouise} 701 | #' \item \code{provence} 702 | #' \item \code{halong} 703 | #' \item \code{vatnajokull} 704 | #' \item \code{arashiyama} 705 | #' \item \code{mountcook} 706 | #' \item \code{benagil} 707 | #' \item \code{bryce} 708 | #' \item \code{jozi} 709 | #' \item \code{main} 710 | #' } \cr 711 | #' Palette Colors inspired by: \cr 712 | #' https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 713 | #' Palette made ffg blog post: \cr 714 | #' https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 715 | #' 716 | #' @param palette Character name of palette in nature_palettes 717 | #' @param discrete Boolean indicating whether colour aesthetic is discrete or not 718 | #' @param reverse Boolean indicating whether the palette should be reversed 719 | #' @param ... Additional arguments passed to discrete_scale() or 720 | #' scale_fill_gradientn(), used respectively when discrete is TRUE or FALSE 721 | #' 722 | #' @return Fill scale of nature palette 723 | #' @importFrom ggplot2 discrete_scale scale_fill_gradientn 724 | #' @examples 725 | #' # Fill by discrete variable with different palette + remove legend (guide) 726 | #' library(ggplot2) 727 | #' ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 728 | #' geom_bar() + 729 | #' theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 730 | #' scale_fill_nature(palette = "vatnajokull", guide = "none") 731 | #' @export 732 | scale_fill_nature <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) { 733 | pal <- nature_pal(palette = palette, reverse = reverse) 734 | 735 | if (discrete) { 736 | ggplot2::discrete_scale("fill", paste0("nature_", palette), palette = pal, ...) 737 | } else { 738 | ggplot2::scale_fill_gradientn(colours = pal(256), ...) 739 | } 740 | } 741 | 742 | #' Creates RColorBrewer like palette viewers for the disney and nature palettes 743 | #' @param pal Character name of palette to display colours for - disney or nature, here 744 | #' @return A heatmap of the colours for the disney and nature palettes 745 | #' @export 746 | #' @importFrom graphics rect par image text plot 747 | #' @examples 748 | #' # View the disney colours 749 | #' werpals_display(pal = "disney") 750 | #' # View the nature colours 751 | #' werpals_display(pal = "nature") 752 | werpals_display <- function(pal) { 753 | if (is.null(pal) | !(pal %in% c("disney", "nature")) ) 754 | stop("Palette not found. The `pal` argument may be 'disney' or 'nature'") 755 | 756 | if (pal == "disney") { 757 | pal <- disney_palettes[-1] 758 | } 759 | else if (pal == "nature") { 760 | pal <- nature_palettes[-1] 761 | } 762 | 763 | col.number <- lengths(pal) 764 | nr <- length(pal) 765 | nc <- max(col.number) 766 | 767 | ylim <- c(0, nr) 768 | oldpar <- par(mgp=c(2,0.25,0)) 769 | on.exit(par(oldpar)) 770 | plot(1, 1, xlim = c(0,nc), ylim = ylim, type = "n", axes = FALSE, bty = "n", 771 | xlab = "", ylab = "") 772 | 773 | for(i in 1:nr){ 774 | nj <- col.number[i] 775 | shadi <- pal[[names(pal)[i]]] 776 | rect(xleft=0:(nj-1), ybottom=i-1, xright=1:nj, ytop=i-0.2, col=shadi, border="light grey") 777 | } 778 | text(rep(-0.15,nr),(1:nr)-0.6, labels=names(pal), xpd=TRUE, adj=1, cex = 0.7, srt = 45) 779 | } 780 | 781 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | # werpals 17 | Pronounced __`We Are Pals`__ [pals for palettes ;)] 18 | 19 | ## Palettes inspired by nature and disney films 20 | 21 | 22 | 23 | 24 | Palette Colours inspired from a blog post [here](http://elijahmeeks.com/#content/blog/2015_08_17_palettes) and [here](https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e). 25 | Palette made following this blog post [here](https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2). 26 | 27 | 28 | 29 | 30 | 31 | The goal of werpals is to provide a few additional palettes to use with your ggplot plots. 32 | 33 | ## Installation - __The development version__ 34 | 35 | You can install the development version from [GitHub](https://github.com/) with: 36 | 37 | ```{r, eval = FALSE} 38 | devtools::install_github("sciencificity/werpals") 39 | ``` 40 | 41 | ## Usage 42 | 43 | There are a few functions that may be used with ggplot2 plots: 44 | 45 | __Disney Like Colours -__ 46 | 47 | * scale_colour_disney() OR scale_color_disney() for one of the disney-like palettes to be applied. 48 | * scale_fill_disney() to fill with disney-like palette. 49 | 50 | __Nature Like Colours -__ 51 | 52 | * scale_colour_nature() OR scale_color_nature() for one of the nature like palettes to be applied. 53 | * scale_fill_nature() to fill with nature like palette. 54 | 55 | __See the palettes -__ 56 | 57 | Call `werpals_display(pal = "nature")` or `werpals_display(pal = "disney")` to view the palettes available in each. Thanks to Jonathan Kitt for this lovely addition! 58 | 59 | ### Example Code 60 | You may run the examples in the code below to see the difference in applying these colour scales. In addition use the help functions and navigate to the bottom of the help page where you will find some examples. 61 | 62 | * ?scale_colour_disney 63 | * ?scale_fill_disney 64 | * ?scale_colour_nature 65 | * ?scale_fill_nature 66 | 67 | ```{r example, message = FALSE, warning = FALSE, eval = FALSE} 68 | library(werpals) 69 | library(tidyverse) 70 | 71 | # See all palettes of disney 72 | names(disney_palettes) 73 | 74 | # See all palettes of nature 75 | names(nature_palettes) 76 | 77 | # See number discrete values in "main" the combo palette 78 | str_glue("The number of discrete colours in the `main` disney palette is: {length(disney_palettes[['main']])}") 79 | 80 | # See number discrete values in "main" the combo palette 81 | str_glue("The number of discrete colours in the `main` nature palette is: {length(nature_palettes[['main']])}") 82 | 83 | # Examples taken from ?scale_colour_discrete and amended 84 | dsamp <- diamonds[sample(nrow(diamonds), 1000), ] 85 | (d <- ggplot(dsamp, aes(carat, price)) + geom_point(aes(colour = clarity))) 86 | # Change scale to disney default 87 | d + scale_colour_disney() 88 | # Change scale to disney - `alice` palette 89 | d + scale_colour_disney("alice") 90 | 91 | # Lookup colours of one palette 92 | disney_palettes[["cinderella"]] 93 | 94 | # Another example taken from ?scale_colour_discrete and amended 95 | miss <- factor(sample(c(NA, 1:5), nrow(mtcars), replace = TRUE)) 96 | ggplot(mtcars, aes(mpg, wt)) + 97 | geom_point(aes(colour = miss)) + 98 | scale_colour_disney(palette = "when_i_was_your_age", na.value = "black") 99 | 100 | # Fill by discrete variable with different palette + remove legend (guide) 101 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 102 | geom_bar() + 103 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 104 | scale_fill_nature(palette = "jozi", guide = "none") 105 | ``` 106 | 107 | ```{r, message = FALSE, warning = FALSE, eval = FALSE} 108 | # Recreate the plots displayed in the images below 109 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 110 | geom_bar() + 111 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 112 | scale_fill_nature(palette = "provence", guide = "none") 113 | 114 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 115 | geom_bar() + 116 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 117 | scale_fill_disney(palette = "cinderella", guide = "none") 118 | ``` 119 | ```{r, echo = FALSE, eval = FALSE} 120 | library(cowplot) 121 | library(magick) 122 | p1 <- ggdraw() + draw_image("man/figures/provence_blog.PNG", scale = 1) 123 | p2 <- ggdraw() + draw_image("man/figures/ggplot_provence.png") 124 | 125 | plot_grid(p1, p2) 126 | 127 | p1 <- ggdraw() + draw_image("man/figures/cinderella_blog.PNG") 128 | p2 <- ggdraw() + draw_image("man/figures/ggplot_cinderella.png") 129 | 130 | plot_grid(p1, p2) 131 | ``` 132 | 133 | ### The Disney Colours 134 | 135 | ```{r, eval = TRUE} 136 | werpals::werpals_display("disney") 137 | ``` 138 | 139 | ### The Nature Colours 140 | ```{r} 141 | werpals::werpals_display("nature") 142 | ``` 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | ### Getting help 151 | 152 | 153 | 154 | ### Using the scale_fill_disney 155 | 156 | 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # werpals 5 | 6 | Pronounced **`We Are Pals`** \[pals for palettes ;)\] 7 | 8 | ## Palettes inspired by nature and disney films 9 | 10 | 11 | 12 | Palette Colours inspired from a blog post 13 | [here](http://elijahmeeks.com/#content/blog/2015_08_17_palettes) and 14 | [here](https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e). 15 | Palette made following this blog post 16 | [here](https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2). 17 | 18 | 19 | 20 | 21 | 22 | The goal of werpals is to provide a few additional palettes to use with 23 | your ggplot plots. 24 | 25 | ## Installation - **The development version** 26 | 27 | You can install the development version from 28 | [GitHub](https://github.com/) with: 29 | 30 | ``` r 31 | devtools::install_github("sciencificity/werpals") 32 | ``` 33 | 34 | ## Usage 35 | 36 | There are a few functions that may be used with ggplot2 plots: 37 | 38 | **Disney Like Colours -** 39 | 40 | - scale\_colour\_disney() OR scale\_color\_disney() for one of the 41 | disney-like palettes to be applied. 42 | - scale\_fill\_disney() to fill with disney-like palette. 43 | 44 | **Nature Like Colours -** 45 | 46 | - scale\_colour\_nature() OR scale\_color\_nature() for one of the 47 | nature like palettes to be applied. 48 | - scale\_fill\_nature() to fill with nature like palette. 49 | 50 | **See the palettes -** 51 | 52 | Call `werpals_display(pal = "nature")` or `werpals_display(pal = 53 | "disney")` to view the palettes available in each. Thanks to Jonathan 54 | Kitt for this lovely addition\! 55 | 56 | ### Example Code 57 | 58 | You may run the examples in the code below to see the difference in 59 | applying these colour scales. In addition use the help functions and 60 | navigate to the bottom of the help page where you will find some 61 | examples. 62 | 63 | - ?scale\_colour\_disney 64 | - ?scale\_fill\_disney 65 | - ?scale\_colour\_nature 66 | - ?scale\_fill\_nature 67 | 68 | 69 | 70 | ``` r 71 | library(werpals) 72 | library(tidyverse) 73 | 74 | # See all palettes of disney 75 | names(disney_palettes) 76 | 77 | # See all palettes of nature 78 | names(nature_palettes) 79 | 80 | # See number discrete values in "main" the combo palette 81 | str_glue("The number of discrete colours in the `main` disney palette is: {length(disney_palettes[['main']])}") 82 | 83 | # See number discrete values in "main" the combo palette 84 | str_glue("The number of discrete colours in the `main` nature palette is: {length(nature_palettes[['main']])}") 85 | 86 | # Examples taken from ?scale_colour_discrete and amended 87 | dsamp <- diamonds[sample(nrow(diamonds), 1000), ] 88 | (d <- ggplot(dsamp, aes(carat, price)) + geom_point(aes(colour = clarity))) 89 | # Change scale to disney default 90 | d + scale_colour_disney() 91 | # Change scale to disney - `alice` palette 92 | d + scale_colour_disney("alice") 93 | 94 | # Lookup colours of one palette 95 | disney_palettes[["cinderella"]] 96 | 97 | # Another example taken from ?scale_colour_discrete and amended 98 | miss <- factor(sample(c(NA, 1:5), nrow(mtcars), replace = TRUE)) 99 | ggplot(mtcars, aes(mpg, wt)) + 100 | geom_point(aes(colour = miss)) + 101 | scale_colour_disney(palette = "when_i_was_your_age", na.value = "black") 102 | 103 | # Fill by discrete variable with different palette + remove legend (guide) 104 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 105 | geom_bar() + 106 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 107 | scale_fill_nature(palette = "jozi", guide = "none") 108 | ``` 109 | 110 | ``` r 111 | # Recreate the plots displayed in the images below 112 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 113 | geom_bar() + 114 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 115 | scale_fill_nature(palette = "provence", guide = "none") 116 | 117 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 118 | geom_bar() + 119 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 120 | scale_fill_disney(palette = "cinderella", guide = "none") 121 | ``` 122 | 123 | ### The Disney Colours 124 | 125 | ``` r 126 | werpals::werpals_display("disney") 127 | ``` 128 | 129 | 130 | 131 | ### The Nature Colours 132 | 133 | ``` r 134 | werpals::werpals_display("nature") 135 | ``` 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | ### Getting help 146 | 147 | 148 | 149 | ### Using the scale\_fill\_disney 150 | 151 | 152 | -------------------------------------------------------------------------------- /man/disney_colours.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \docType{data} 4 | \name{disney_colours} 5 | \alias{disney_colours} 6 | \title{The list of disney colours} 7 | \format{An object of class \code{character} of length 45.} 8 | \usage{ 9 | disney_colours 10 | } 11 | \description{ 12 | The list of disney colours 13 | } 14 | \keyword{datasets} 15 | -------------------------------------------------------------------------------- /man/disney_cols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{disney_cols} 4 | \alias{disney_cols} 5 | \title{Function to extract colours as hex codes} 6 | \usage{ 7 | disney_cols(...) 8 | } 9 | \arguments{ 10 | \item{...}{Character names of disney_colours} 11 | } 12 | \description{ 13 | Function to extract colours as hex codes 14 | } 15 | -------------------------------------------------------------------------------- /man/disney_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{disney_pal} 4 | \alias{disney_pal} 5 | \title{Return function to interpolate a disney colour palette} 6 | \usage{ 7 | disney_pal(palette = "main", reverse = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{palette}{Character name of palette in disney_palettes} 11 | 12 | \item{reverse}{Boolean indicating whether the palette should be reversed} 13 | 14 | \item{...}{Additional arguments to pass to colorRampPalette()} 15 | } 16 | \description{ 17 | Return function to interpolate a disney colour palette 18 | } 19 | -------------------------------------------------------------------------------- /man/disney_palettes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \docType{data} 4 | \name{disney_palettes} 5 | \alias{disney_palettes} 6 | \title{Function to create palettes} 7 | \format{An object of class \code{list} of length 8.} 8 | \usage{ 9 | disney_palettes 10 | } 11 | \description{ 12 | Function to create palettes 13 | } 14 | \keyword{datasets} 15 | -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/README-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /man/figures/README-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/README-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /man/figures/alice.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/alice.PNG -------------------------------------------------------------------------------- /man/figures/apply.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/apply.gif -------------------------------------------------------------------------------- /man/figures/cinderella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/cinderella.png -------------------------------------------------------------------------------- /man/figures/cinderella_blog.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/cinderella_blog.PNG -------------------------------------------------------------------------------- /man/figures/ggplot_cinderella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/ggplot_cinderella.png -------------------------------------------------------------------------------- /man/figures/ggplot_provence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/ggplot_provence.png -------------------------------------------------------------------------------- /man/figures/ggplot_uyuni.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/ggplot_uyuni.png -------------------------------------------------------------------------------- /man/figures/help1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/help1.gif -------------------------------------------------------------------------------- /man/figures/provence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/provence.png -------------------------------------------------------------------------------- /man/figures/provence_blog.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/provence_blog.PNG -------------------------------------------------------------------------------- /man/figures/uyuni.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/uyuni.png -------------------------------------------------------------------------------- /man/figures/uyuni_blog.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciencificity/werpals/ae09f45589e02766e7985049013b386d87b0cb34/man/figures/uyuni_blog.PNG -------------------------------------------------------------------------------- /man/nature_colours.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \docType{data} 4 | \name{nature_colours} 5 | \alias{nature_colours} 6 | \title{The list of nature colours} 7 | \format{An object of class \code{character} of length 110.} 8 | \usage{ 9 | nature_colours 10 | } 11 | \description{ 12 | The list of nature colours 13 | } 14 | \keyword{datasets} 15 | -------------------------------------------------------------------------------- /man/nature_cols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{nature_cols} 4 | \alias{nature_cols} 5 | \title{Function to extract colours as hex codes} 6 | \usage{ 7 | nature_cols(...) 8 | } 9 | \arguments{ 10 | \item{...}{Character names of nature_colours} 11 | } 12 | \description{ 13 | Function to extract colours as hex codes 14 | } 15 | -------------------------------------------------------------------------------- /man/nature_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{nature_pal} 4 | \alias{nature_pal} 5 | \title{Return function to interpolate a nature colour palette} 6 | \usage{ 7 | nature_pal(palette = "main", reverse = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{palette}{Character name of palette in nature_palettes} 11 | 12 | \item{reverse}{Boolean indicating whether the palette should be reversed} 13 | 14 | \item{...}{Additional arguments to pass to colorRampPalette()} 15 | } 16 | \description{ 17 | Return function to interpolate a nature colour palette 18 | } 19 | -------------------------------------------------------------------------------- /man/nature_palettes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \docType{data} 4 | \name{nature_palettes} 5 | \alias{nature_palettes} 6 | \title{Function to create palettes} 7 | \format{An object of class \code{list} of length 12.} 8 | \usage{ 9 | nature_palettes 10 | } 11 | \description{ 12 | Function to create palettes 13 | } 14 | \keyword{datasets} 15 | -------------------------------------------------------------------------------- /man/scale_color_disney.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_color_disney} 4 | \alias{scale_color_disney} 5 | \title{Color scale constructor for some disney-ish colors} 6 | \usage{ 7 | scale_color_disney(palette = "main", discrete = TRUE, 8 | reverse = FALSE, ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in disney_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether color aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_color_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Colour scale of disney-like palette 22 | } 23 | \description{ 24 | This is the default colour scale for categorical variables for the disney-like palette. 25 | It does not generate colour-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{cinderella} 29 | \item \code{monet} 30 | \item \code{small_world} 31 | \item \code{alice} 32 | \item \code{pan} 33 | \item \code{when_i_was_your_age} 34 | \item \code{firefly} 35 | \item \code{main} 36 | } \cr 37 | Palette Colours inspired by: \cr 38 | http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 39 | Palette made ffg blog post: \cr 40 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 41 | } 42 | \examples{ 43 | # Color by discrete variable using default palette 44 | library(ggplot2) 45 | ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + 46 | geom_point(size = 4) + 47 | scale_color_disney() 48 | } 49 | -------------------------------------------------------------------------------- /man/scale_color_nature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_color_nature} 4 | \alias{scale_color_nature} 5 | \title{Color scale constructor for some nature colors} 6 | \usage{ 7 | scale_color_nature(palette = "main", discrete = TRUE, 8 | reverse = FALSE, ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in nature_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether color aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_color_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Color scale of natural palette 22 | } 23 | \description{ 24 | This is the default color scale for categorical variables for the nature palette. 25 | It does not generate color-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{uyuni} 29 | \item \code{okavango} 30 | \item \code{lakelouise} 31 | \item \code{provence} 32 | \item \code{halong} 33 | \item \code{vatnajokull} 34 | \item \code{arashiyama} 35 | \item \code{mountcook} 36 | \item \code{benagil} 37 | \item \code{bryce} 38 | \item \code{jozi} 39 | \item \code{main} 40 | } \cr 41 | Palette Colors inspired by: \cr 42 | https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 43 | Palette made ffg blog post: \cr 44 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 45 | } 46 | \examples{ 47 | # Color using the `lakelouise` palette 48 | library(ggplot2) 49 | ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 50 | geom_point(size = 4, alpha = .8) + 51 | scale_color_nature( 52 | discrete = FALSE, 53 | palette = "lakelouise", 54 | guide = "none" 55 | ) + 56 | facet_wrap(~cyl) + 57 | theme_dark() 58 | 59 | # Colour using the `jozi` palette, and where cyl is discrete 60 | library(ggplot2) 61 | ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 62 | geom_point(size = 4, alpha = .8) + 63 | scale_color_nature( 64 | discrete = TRUE, 65 | palette = "jozi", 66 | guide = "none" 67 | ) + 68 | facet_wrap(~cyl) 69 | } 70 | -------------------------------------------------------------------------------- /man/scale_colour_disney.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_colour_disney} 4 | \alias{scale_colour_disney} 5 | \title{Colour scale constructor for some disney-ish colours} 6 | \usage{ 7 | scale_colour_disney(palette = "main", discrete = TRUE, 8 | reverse = FALSE, ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in disney_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether colour aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_color_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Colour scale of disney-like palette 22 | } 23 | \description{ 24 | This is the default colour scale for categorical variables for the disney-like palette. 25 | It does not generate colour-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{cinderella} 29 | \item \code{monet} 30 | \item \code{small_world} 31 | \item \code{alice} 32 | \item \code{pan} 33 | \item \code{when_i_was_your_age} 34 | \item \code{firefly} 35 | \item \code{main} 36 | } \cr 37 | Palette Colours inspired by: \cr 38 | http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 39 | Palette made ffg blog post: \cr 40 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 41 | } 42 | \examples{ 43 | # Colour using the small_world palette 44 | library(ggplot2) 45 | ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 46 | geom_point(size = 4, alpha = .8) + 47 | scale_colour_disney( 48 | discrete = FALSE, 49 | palette = "small_world", 50 | guide = "none" 51 | ) + 52 | facet_wrap(~cyl) 53 | 54 | # Colour using the `alice` palette, and where cyl is discrete 55 | library(ggplot2) 56 | ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 57 | geom_point(size = 4, alpha = .8) + 58 | scale_colour_disney( 59 | discrete = TRUE, 60 | palette = "alice", 61 | guide = "none" 62 | ) + 63 | facet_wrap(~cyl) 64 | } 65 | -------------------------------------------------------------------------------- /man/scale_colour_nature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_colour_nature} 4 | \alias{scale_colour_nature} 5 | \title{Colour scale constructor for some nature colours} 6 | \usage{ 7 | scale_colour_nature(palette = "main", discrete = TRUE, 8 | reverse = FALSE, ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in nature_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether colour aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_color_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Colour scale of natural palette 22 | } 23 | \description{ 24 | This is the default colour scale for categorical variables for the nature palette. 25 | It does not generate colour-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{uyuni} 29 | \item \code{okavango} 30 | \item \code{lakelouise} 31 | \item \code{provence} 32 | \item \code{halong} 33 | \item \code{vatnajokull} 34 | \item \code{arashiyama} 35 | \item \code{mountcook} 36 | \item \code{benagil} 37 | \item \code{bryce} 38 | \item \code{jozi} 39 | \item \code{main} 40 | } \cr 41 | Palette Colours inspired by: \cr 42 | https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 43 | Palette made ffg blog post: \cr 44 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 45 | } 46 | \examples{ 47 | # Colour using the `okavango` palette 48 | library(ggplot2) 49 | ggplot(mtcars, aes(hp, mpg, colour = cyl)) + 50 | geom_point(size = 4, alpha = .8) + 51 | scale_colour_nature( 52 | discrete = FALSE, 53 | palette = "uyuni", 54 | guide = "none" 55 | ) + 56 | facet_wrap(~cyl) + 57 | theme_dark() 58 | 59 | # Colour using the `halong` palette, and where cyl is discrete 60 | library(ggplot2) 61 | ggplot(mtcars, aes(hp, mpg, colour = as.factor(cyl))) + 62 | geom_point(size = 4, alpha = .8) + 63 | scale_colour_nature( 64 | discrete = TRUE, 65 | palette = "halong", 66 | guide = "none" 67 | ) + 68 | facet_wrap(~cyl) 69 | } 70 | -------------------------------------------------------------------------------- /man/scale_fill_disney.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_fill_disney} 4 | \alias{scale_fill_disney} 5 | \title{Fill scale constructor for some disney-ish colours} 6 | \usage{ 7 | scale_fill_disney(palette = "main", discrete = TRUE, reverse = FALSE, 8 | ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in disney_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether colour aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_fill_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Fill scale of disney-like palette 22 | } 23 | \description{ 24 | This is the default fill scale for the disney-like palette. 25 | It does not generate colour-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{cinderella} 29 | \item \code{monet} 30 | \item \code{small_world} 31 | \item \code{alice} 32 | \item \code{pan} 33 | \item \code{when_i_was_your_age} 34 | \item \code{firefly} 35 | \item \code{main} 36 | } \cr 37 | Palette Colours inspired by: \cr 38 | http://elijahmeeks.com/#content/blog/2015_08_17_palettes \cr \cr 39 | Palette made ffg blog post: \cr 40 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 41 | } 42 | \examples{ 43 | # Fill by discrete variable with different palette + remove legend (guide) 44 | library(ggplot2) 45 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 46 | geom_bar() + 47 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 48 | scale_fill_disney(palette = "main", guide = "none") 49 | } 50 | -------------------------------------------------------------------------------- /man/scale_fill_nature.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{scale_fill_nature} 4 | \alias{scale_fill_nature} 5 | \title{Fill scale constructor for some nature colours} 6 | \usage{ 7 | scale_fill_nature(palette = "main", discrete = TRUE, reverse = FALSE, 8 | ...) 9 | } 10 | \arguments{ 11 | \item{palette}{Character name of palette in nature_palettes} 12 | 13 | \item{discrete}{Boolean indicating whether colour aesthetic is discrete or not} 14 | 15 | \item{reverse}{Boolean indicating whether the palette should be reversed} 16 | 17 | \item{...}{Additional arguments passed to discrete_scale() or 18 | scale_fill_gradientn(), used respectively when discrete is TRUE or FALSE} 19 | } 20 | \value{ 21 | Fill scale of nature palette 22 | } 23 | \description{ 24 | This is the default fill scale for the nature palette. 25 | It does not generate colour-blind safe palettes. 26 | These are the palettes to choose from: 27 | \itemize{ 28 | \item \code{uyuni} 29 | \item \code{okavango} 30 | \item \code{lakelouise} 31 | \item \code{provence} 32 | \item \code{halong} 33 | \item \code{vatnajokull} 34 | \item \code{arashiyama} 35 | \item \code{mountcook} 36 | \item \code{benagil} 37 | \item \code{bryce} 38 | \item \code{jozi} 39 | \item \code{main} 40 | } \cr 41 | Palette Colors inspired by: \cr 42 | https://medium.com/sketch-app-sources/10-color-palettes-from-the-natural-world-to-inspire-your-creative-streak-bc2fb73d161e \cr \cr 43 | Palette made ffg blog post: \cr 44 | https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2 \cr 45 | } 46 | \examples{ 47 | # Fill by discrete variable with different palette + remove legend (guide) 48 | library(ggplot2) 49 | ggplot(mpg, aes(manufacturer, fill = manufacturer)) + 50 | geom_bar() + 51 | theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 52 | scale_fill_nature(palette = "vatnajokull", guide = "none") 53 | } 54 | -------------------------------------------------------------------------------- /man/werpals_display.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/werpals.R 3 | \name{werpals_display} 4 | \alias{werpals_display} 5 | \title{Creates RColorBrewer like palette viewers for the disney and nature palettes} 6 | \usage{ 7 | werpals_display(pal) 8 | } 9 | \arguments{ 10 | \item{pal}{Character name of palette to display colours for - disney or nature, here} 11 | } 12 | \value{ 13 | A heatmap of the colours for the disney and nature palettes 14 | } 15 | \description{ 16 | Creates RColorBrewer like palette viewers for the disney and nature palettes 17 | } 18 | \examples{ 19 | # View the disney colours 20 | werpals_display(pal = "disney") 21 | # View the nature colours 22 | werpals_display(pal = "nature") 23 | } 24 | -------------------------------------------------------------------------------- /werpals.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 4 10 | Encoding: ISO8859-1 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace,vignette 22 | --------------------------------------------------------------------------------