Title: | Colors and Palettes from Color-Hex |
---|---|
Description: | The website <https://www.color-hex.com> is a great resource of hex colour codes and palettes. This package allows you to retrieve palettes and colour information from the website directly from R. There are also custom scale-functions for 'ggplot2'. |
Authors: | Athanasia Mo Mowinckel [aut, cre] , Julia Romanowska [ctb] |
Maintainer: | Athanasia Mo Mowinckel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.4 |
Built: | 2024-11-09 03:52:28 UTC |
Source: | https://github.com/drmowinckels/colorhex |
Get color information from www.color-hex.com of a hex-color.
get_color(hex)
get_color(hex)
hex |
character string that is a hexidecimal color |
list of class 'colorhex'
if(curl::has_internet()){ get_color("#470f0f") }
if(curl::has_internet()){ get_color("#470f0f") }
Retrieve the most recently made palettes from www.color-hex.com
get_latest_palettes()
get_latest_palettes()
data.frame with name, id and colours
if(curl::has_internet()){ get_latest_palettes() }
if(curl::has_internet()){ get_latest_palettes() }
Get palette information from www.color-hex.com based on the palette id (can be found in the url)
get_palette(id)
get_palette(id)
id |
numeric id of a palette |
data.frame with palette information
if(curl::has_internet()){ get_palette(103107) # Lookup multiple palettes id <- c(103161, 103107) get_palette(id) }
if(curl::has_internet()){ get_palette(103107) # Lookup multiple palettes id <- c(103161, 103107) get_palette(id) }
www.color-hex.com has a list of colours that have been liked by the most users. This function will retrieve all of these.
get_popular_colors()
get_popular_colors()
character vector of hex colours
if(curl::has_internet()){ get_popular_colors() }
if(curl::has_internet()){ get_popular_colors() }
Retrieve the palettes most users have checked as favorites from www.color-hex.com
get_popular_palettes()
get_popular_palettes()
data.frame with name, id and colours
if(curl::has_internet()){ get_popular_palettes() }
if(curl::has_internet()){ get_popular_palettes() }
Generate random HEX colour
get_random_color()
get_random_color()
character hex value
get_random_color()
get_random_color()
validate if string is hexidecimal color code
is_hex(x)
is_hex(x)
x |
hexidecimal character |
logical. TRUE if object is a hexidecimal code
Colour and fill scales for ggplot2
plots, using object of class colorhex
as basis for colour choices.
scale_colour_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_color_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_fill_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_colour_colorhex_c(x, type = "complementary", reverse = FALSE, ...) scale_color_colorhex_c(x, type = "complementary", reverse = FALSE, ...) scale_fill_colorhex_c(x, type = "complementary", reverse = FALSE, ...)
scale_colour_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_color_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_fill_colorhex_d(x, type = "triadic", reverse = FALSE, ...) scale_colour_colorhex_c(x, type = "complementary", reverse = FALSE, ...) scale_color_colorhex_c(x, type = "complementary", reverse = FALSE, ...) scale_fill_colorhex_c(x, type = "complementary", reverse = FALSE, ...)
x |
object of class |
type |
character. Type of colours to use. One of c("complementary", "triadic" (default), "shades", "tints", "related") |
reverse |
logical. If scale should b reversed (default: FALSE) |
... |
arguments to be passed to |
The colorhex
class is a list where there
is a variety of extra information on the hex
colour selected. This information can be used
to create colour scales to be used in ggplot2.
a ggplot2-proto
scale_colour_colorhex_d()
: Discrete colour scale
scale_color_colorhex_d()
: Discrete colour scale
scale_fill_colorhex_d()
: Discrete fill scale
scale_colour_colorhex_c()
: Continuous colour scale
scale_color_colorhex_c()
: Continuous colour scale
scale_fill_colorhex_c()
: Continuous fill scale
if(curl::has_internet()){ library(ggplot2) x <- get_color("#008080") ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x) ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x, "tints") ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x, "shades") ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_colorhex_d(x, "triadic") ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_colorhex_d(x, "shades") }
if(curl::has_internet()){ library(ggplot2) x <- get_color("#008080") ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x) ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x, "tints") ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_colorhex_c(x, "shades") ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_colorhex_d(x, "triadic") ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_colorhex_d(x, "shades") }
Colour and fill scales for ggplot2
plots, using object of class palettehex
.
scale_colour_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_color_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_fill_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_colour_palettehex_c(x, which = 1, reverse = FALSE, ...) scale_color_palettehex_c(x, which = 1, reverse = FALSE, ...) scale_fill_palettehex_c(x, which = 1, reverse = FALSE, ...)
scale_colour_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_color_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_fill_palettehex_d(x, which = 1, reverse = FALSE, ...) scale_colour_palettehex_c(x, which = 1, reverse = FALSE, ...) scale_color_palettehex_c(x, which = 1, reverse = FALSE, ...) scale_fill_palettehex_c(x, which = 1, reverse = FALSE, ...)
x |
object of class |
which |
selection of which palette of a set to choose. Either by name, id or numeric index. |
reverse |
logical. If scale should b reversed (default: FALSE) |
... |
arguments to be passed to |
The palettehex
class is a data.frame of
many palettes. This function takes such a data.frame
and a choice of palette by name, id or numeric index
can be made for the scale.
ggplot2-proto
scale_colour_palettehex_d()
: Discrete colour scale
scale_color_palettehex_d()
: Discrete colour scale
scale_fill_palettehex_d()
: Discrete fill scale
scale_colour_palettehex_c()
: Continuous colour scale
scale_color_palettehex_c()
: Continuous colour scale
scale_fill_palettehex_c()
: Continuous fill scale
if(curl::has_internet()){ library(ggplot2) x <- get_popular_palettes() ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_palettehex_c(x) ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_palettehex_c(x, 3) ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_palettehex_d(x) ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_palettehex_d(x, 1872) }
if(curl::has_internet()){ library(ggplot2) x <- get_popular_palettes() ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_palettehex_c(x) ggplot(mtcars, aes(mpg)) + geom_density(aes(fill = disp, group = disp)) + scale_fill_palettehex_c(x, 3) ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_palettehex_d(x) ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_palettehex_d(x, 1872) }