Title: | 'cpt-city' Colour Gradients |
---|---|
Description: | Incorporates colour gradients from the 'cpt-city' web archive available at <http://soliton.vm.bytemark.co.uk/pub/cpt-city/>. |
Authors: | Sergio Ibarra-Espinosa [aut, cre] |
Maintainer: | Sergio Ibarra-Espinosa <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-10-21 02:45:34 UTC |
Source: | https://github.com/ibarraespinosa/cptcity |
This function return a collor palette based on the name or position of the palette.
cpt( pal = "mpl_inferno", n = 100, colorRampPalette = FALSE, rev = FALSE, frgb = rep(1, 3) )
cpt( pal = "mpl_inferno", n = 100, colorRampPalette = FALSE, rev = FALSE, frgb = rep(1, 3) )
pal |
Palette of colors available or the number of the position |
n |
integer; number of colors |
colorRampPalette |
Logical; to be used in sf and mapview. |
rev |
Logical; to internally revert order of rgb color vectors. |
frgb |
Numeric; vector of 3 to change internal rgb composition. The order is red, green, blue |
The cpt-city web archive comes from: http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html
A colour palette function.
{ library(cptcity) image(matrix(1:100), col = cpt(pal = "mpl_inferno")) find_cpt("temperature") image(matrix(1:100), col = cpt("idv_temperature")) image(matrix(1:100), col = cpt("idv_temperature", rev = TRUE)) ## Not run: # Do not run library(ggplot2) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(n = 100)) ## End(Not run) }
{ library(cptcity) image(matrix(1:100), col = cpt(pal = "mpl_inferno")) find_cpt("temperature") image(matrix(1:100), col = cpt("idv_temperature")) image(matrix(1:100), col = cpt("idv_temperature", rev = TRUE)) ## Not run: # Do not run library(ggplot2) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(n = 100)) ## End(Not run) }
This dataset os a vector with al the names of the gradients of the archive cptcity (http://soliton.vm.bytemark.co.uk/pub/cpt-city/) availale in this package. Please, read the documentation of each color gradient in the web page shown above.
data(cpt_names)
data(cpt_names)
A vector with the 7140 names of the color gradients
http://soliton.vm.bytemark.co.uk/pub/cpt-city/
Colour palettes comes from http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html
Rhw function cpt
has two arguments n for the numbers
and pal for the name or number of the palette:
The palettes are available here: http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html
find_cpt
returns the name of the colour gradient that satisfy
the search. It is a searcher. It is a mini mini mini google.
find_cpt(name)
find_cpt(name)
name |
character; Word to be searched among the names of the cpt gradients. |
names that satisfy the search.
This functions runs grep.
{ library(cptcity) find_cpt("temperature") image(matrix(1:100), col = cpt("idv_temperature")) ## Not run: library(cptcity) # Do not run # data names_cpt lazy loaded, already in environment library(ggplot2) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) find_cpt("radar") ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(n = 10, "ncl_radar")) find_cpt("rain") ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(pal = "pj_1_a_rainbow")) ## End(Not run) }
{ library(cptcity) find_cpt("temperature") image(matrix(1:100), col = cpt("idv_temperature")) ## Not run: library(cptcity) # Do not run # data names_cpt lazy loaded, already in environment library(ggplot2) ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) find_cpt("radar") ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(n = 10, "ncl_radar")) find_cpt("rain") ggplot(faithfuld, aes(waiting, eruptions)) + geom_raster(aes(fill = density)) + scale_fill_gradientn(colours = cpt(pal = "pj_1_a_rainbow")) ## End(Not run) }
Based on "I'm Feeling Lucky" from Google. As this package includes 7140 colour gradients, it might be hard to find the 'right'
lucky( n = 100, colorRampPalette = FALSE, rev = FALSE, message = TRUE, nseed, frgb = rep(1, 3) )
lucky( n = 100, colorRampPalette = FALSE, rev = FALSE, message = TRUE, nseed, frgb = rep(1, 3) )
n |
integer; number of colors |
colorRampPalette |
Logical; to be used in sf and mapview. |
rev |
Logical; to internally revert order of rgb color vectors. |
message |
Logical; for printing or not the name of the colour gradient |
nseed |
integer; for reproducing the same colour gradient.
See |
frgb |
Numeric; vector of 3 to change internal rgb composition The order is red, green, blue |
The cpt-city web archive comes from: http://soliton.vm.bytemark.co.uk/pub/cpt-city/index.html
A RANDOM colour palette function including name of the colour gradient and number.
{ library(cptcity) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky(rev = TRUE)) image(matrix(1:100), col = lucky(nseed = 1)) }
{ library(cptcity) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky()) image(matrix(1:100), col = lucky(rev = TRUE)) image(matrix(1:100), col = lucky(nseed = 1)) }
show_cpt
returns a color matrix which prints
and show the colors
show_cpt(x, label = TRUE)
show_cpt(x, label = TRUE)
x |
character; names of the cpt gradients. |
label |
Logical, to show labels or not. |
names color matrix
{ library(cptcity) show_cpt(find_cpt("radar")) }
{ library(cptcity) show_cpt(find_cpt("radar")) }