Skip to contents

This function generates a custom color palette using the specified colors and number of colors.

Usage

custom_palette(
  colors = c("yellow", "#53CC67", "#009B95", "#00588B", "#4B0055"),
  n = 100
)

Arguments

colors

A vector of colors to create the color palette. Default is c("steelblue", "salmon", "forestgreen").

n

The number of gradient colors in the color palette. Default is 100.

Value

A vector of colors representing the custom color palette.

Examples

# Generate a custom color palette with default colors and 10 colors
custom_palette()
#>   [1] "#FFFF00" "#F8FC04" "#F1FA08" "#EAF80C" "#E3F610" "#DCF414" "#D5F218"
#>   [8] "#CEF01D" "#C7EE21" "#C0EC25" "#B9EA29" "#B2E82D" "#ABE631" "#A4E436"
#>  [15] "#9DE23A" "#96E03E" "#8FDE42" "#88DB46" "#81D94A" "#7AD74F" "#74D553"
#>  [22] "#6DD357" "#66D15B" "#5FCF5F" "#58CD63" "#52CB67" "#4EC969" "#4BC76B"
#>  [29] "#48C56D" "#44C36E" "#41C170" "#3EBF72" "#3ABD74" "#37BB76" "#33B978"
#>  [36] "#30B77A" "#2DB57B" "#29B37D" "#26B17F" "#23AF81" "#1FAD83" "#1CAB85"
#>  [43] "#19A987" "#15A788" "#12A58A" "#0FA38C" "#0BA18E" "#089F90" "#059D92"
#>  [50] "#019B94" "#009994" "#009694" "#009493" "#009193" "#008E93" "#008C92"
#>  [57] "#008992" "#008691" "#008391" "#008191" "#007E90" "#007B90" "#00798F"
#>  [64] "#00768F" "#00738F" "#00718E" "#006E8E" "#006B8D" "#00688D" "#00668D"
#>  [71] "#00638C" "#00608C" "#005E8B" "#005B8B" "#00588B" "#025589" "#055187"
#>  [78] "#084E84" "#0B4A82" "#0E4780" "#11437E" "#143F7C" "#173C7A" "#1A3877"
#>  [85] "#1D3575" "#203173" "#232E71" "#262A6F" "#29276C" "#2C236A" "#2F1F68"
#>  [92] "#321C66" "#351864" "#381562" "#3B115F" "#3E0E5D" "#410A5B" "#440759"
#>  [99] "#470357" "#4B0055"

# Generate a custom color palette with specified colors and 20 colors
custom_palette(colors = c("blue", "red"), n = 20)
#>  [1] "#0000FF" "#0D00F1" "#1A00E4" "#2800D6" "#3500C9" "#4300BB" "#5000AE"
#>  [8] "#5D00A1" "#6B0093" "#780086" "#860078" "#93006B" "#A1005D" "#AE0050"
#> [15] "#BB0043" "#C90035" "#D60028" "#E4001A" "#F1000D" "#FF0000"

# example code
library(pliman)
custom_palette(n = 5)
#> [1] "#FFFF00" "#53CC67" "#009B95" "#00588B" "#4B0055"