### Install ggokabeito from GitHub Source: https://malcolmbarrett.github.io/ggokabeito/index.html Install the development version of the ggokabeito package from GitHub using the devtools package. ```r # install.packages("devtools") devtools::install_github("malcolmbarrett/ggokabeito") ``` -------------------------------- ### Install ggokabeito from CRAN Source: https://malcolmbarrett.github.io/ggokabeito/index.html Install the stable version of the ggokabeito package from CRAN. ```r install.packages("ggokabeito") ``` -------------------------------- ### scale_fill_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Okabe-Ito fill scale for the 'fill' aesthetic. ```APIDOC ## scale_fill_okabe_ito ### Description Okabe-Ito fill scale for the 'fill' aesthetic. ### Arguments * `aesthetics`: Defaults to "fill". * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### scale_colour_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Okabe-Ito color scale for the 'colour' aesthetic. ```APIDOC ## scale_colour_okabe_ito ### Description Okabe-Ito color scale for the 'colour' aesthetic. ### Arguments * `aesthetics`: Defaults to "colour". * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### Okabe-Ito Palette with Alpha Transparency Source: https://malcolmbarrett.github.io/ggokabeito/reference/palette_okabe_ito.html Applies a specified alpha transparency to a subset of the Okabe-Ito palette. Requires an integer vector for the order when alpha is used. ```R palette_okabe_ito(order = c(2, 3, 5), alpha = 0.9) #> [1] "#56B4E9E6" "#009E73E6" "#0072B2E6" ``` -------------------------------- ### scale_color_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Okabe-Ito color scale for the 'color' aesthetic. ```APIDOC ## scale_color_okabe_ito ### Description Okabe-Ito color scale for the 'color' aesthetic. ### Arguments * `aesthetics`: Defaults to "colour". * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### scale_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html A general Okabe-Ito scale function that can be applied to specified aesthetics. ```APIDOC ## scale_okabe_ito ### Description A general Okabe-Ito scale function that can be applied to specified aesthetics. ### Arguments * `aesthetics`: The names of the aesthetics that this scale works with. * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### BibTeX Citation for ggokabeito Source: https://malcolmbarrett.github.io/ggokabeito/authors.html This BibTeX entry can be used to cite the ggokabeito package in academic work. It includes the title, author, year, and relevant URLs. ```bibtex @Manual{ title = {ggokabeito: 'Okabe-Ito' Scales for 'ggplot2' and 'ggraph'}, author = {Malcolm Barrett}, year = {2022}, note = {https://github.com/malcolmbarrett/ggokabeito, https://malcolmbarrett.github.io/ggokabeito/}, } ``` -------------------------------- ### Okabe-Ito Scale Functions Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html These functions define discrete scales for various aesthetics using the Okabe-Ito palette. They can be used for 'color', 'fill', and 'edge_colour' mappings. ```R scale_okabe_ito(aesthetics, order = 1:9, alpha = 1, ...) scale_colour_okabe_ito(aesthetics = "colour", order = 1:9, alpha = NULL, ...) scale_color_okabe_ito(aesthetics = "colour", order = 1:9, alpha = NULL, ...) scale_fill_okabe_ito(aesthetics = "fill", order = 1:9, alpha = NULL, ...) scale_edge_colour_okabe_ito( aesthetics = "edge_colour", order = 1:9, alpha = NULL, ... ) scale_edge_color_okabe_ito( aesthetics = "edge_colour", order = 1:9, alpha = NULL, ... ) ``` -------------------------------- ### Okabe-Ito Palette by Color Name Source: https://malcolmbarrett.github.io/ggokabeito/reference/palette_okabe_ito.html Selects specific colors from the Okabe-Ito palette using their names. The order of names determines the output order. ```R palette_okabe_ito(order = c("bluishgreen", "yellow", "blue")) #> [1] "#009E73" "#F0E442" "#0072B2" ``` -------------------------------- ### Basic ggplot2 Scatter Plot with Okabe-Ito Colors Source: https://malcolmbarrett.github.io/ggokabeito/index.html Demonstrates using scale_color_okabe_ito() for a scatter plot with ggplot2, mapping 'class' to color. ```r library(ggokabeito) library(ggplot2) ggplot(mpg, aes(cty, hwy, color = class)) + geom_point() + scale_color_okabe_ito() ``` -------------------------------- ### scale_edge_colour_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Okabe-Ito edge color scale for the 'edge_colour' aesthetic. ```APIDOC ## scale_edge_colour_okabe_ito ### Description Okabe-Ito edge color scale for the 'edge_colour' aesthetic. ### Arguments * `aesthetics`: Defaults to "edge_colour". * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### Okabe-Ito Palette Default Usage Source: https://malcolmbarrett.github.io/ggokabeito/reference/palette_okabe_ito.html Generates the default Okabe-Ito palette with 9 colors. Black is included as the last color when 9 colors are requested. ```R palette_okabe_ito() #> [1] "#E69F00" "#56B4E9" "#009E73" "#F0E442" "#0072B2" "#D55E00" "#CC79A7" #> [8] "#999999" "#000000" ``` -------------------------------- ### scale_edge_color_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Okabe-Ito edge color scale for the 'edge_colour' aesthetic. ```APIDOC ## scale_edge_color_okabe_ito ### Description Okabe-Ito edge color scale for the 'edge_colour' aesthetic. ### Arguments * `aesthetics`: Defaults to "edge_colour". * `order`: A numeric vector, the order of the colors, or a character vector of color names, of: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is not `NULL`, you must use an integer vector since the colors are not returned with names. * `alpha`: An alpha-transparency level in the range [0,1] (0 means transparent and 1 means opaque). * `...`: Additional arguments passed to `ggplot2::discrete_scale()` ### Value A ggplot or ggraph scale ``` -------------------------------- ### Basic Okabe-Ito Color Scale Source: https://malcolmbarrett.github.io/ggokabeito/reference/scale_okabe_ito.html Applies the Okabe-Ito color scale to a ggplot scatter plot. Ensure 'ggplot2' is loaded. ```R library(ggplot2) ggplot(mpg, aes(cty, hwy, color = class)) + geom_point() + scale_color_okabe_ito() ``` -------------------------------- ### ggraph Edge Link Plot with Okabe-Ito Edge Colors Source: https://malcolmbarrett.github.io/ggokabeito/index.html Applies scale_edge_color_okabe_ito() to a ggraph edge link plot, coloring edges by year. ```r # example from https://www.data-imaginist.com/2017/ggraph-introduction-edges/ library(ggraph, warn.conflicts = FALSE) library(igraph, warn.conflicts = FALSE) graph <- graph_from_data_frame(highschool) pop1957 <- degree( delete_edges(graph, which(E(graph)$year == 1957)), mode = "in" ) pop1958 <- degree( delete_edges(graph, which(E(graph)$year == 1958)), mode = "in" ) V(graph)$pop_devel <- ifelse( pop1957 < pop1958, "increased", ifelse(pop1957 > pop1958, "decreased", "unchanged" ) ) V(graph)$popularity <- pmax(pop1957, pop1958) E(graph)$year <- as.character(E(graph)$year) ggraph(graph, layout = "kk") + geom_edge_link(aes(colour = as.character(year))) + scale_edge_color_okabe_ito() ``` -------------------------------- ### ggplot2 Density Plot with Okabe-Ito Fill and Color Scales Source: https://malcolmbarrett.github.io/ggokabeito/index.html Uses both scale_fill_okabe_ito() and scale_color_okabe_ito() for a density plot, customizing legend titles and alpha. ```r ggplot(mpg, aes(hwy, color = class, fill = class)) + geom_density() + scale_fill_okabe_ito(name = "Class", alpha = .9) + scale_color_okabe_ito(name = "Class") ``` -------------------------------- ### palette_okabe_ito Source: https://malcolmbarrett.github.io/ggokabeito/reference/palette_okabe_ito.html A wrapper around `palette.colors()` that returns the Okabe-Ito palette. It is designed for better compatibility with ggplot2, returning an unnamed vector of colors and placing black at the end when 9 colors are requested. ```APIDOC ## palette_okabe_ito() ### Description Provides the Okabe-Ito color palette, suitable for use with ggplot2. Returns an unnamed vector of colors, with black as the last color when 9 colors are needed. ### Arguments * **order** (numeric or character vector) - Specifies the order of colors. Can be a numeric vector (1-9) or a character vector of color names: "black", "orange", "skyblue", "bluishgreen", "yellow", "blue", "vermillion", "reddishpurple", "gray". If `alpha` is used, an integer vector is required. * **alpha** (numeric) - An alpha-transparency level in the range [0,1]. 0 is transparent, 1 is opaque. * **recycle** (logical) - Determines behavior when `n` (number of colors requested) is greater than the available palette length. Defaults to `FALSE`, which issues a warning. ### Value A character vector of hex color codes. ### Examples ```R palette_okabe_ito() #> [1] "#E69F00" "#56B4E9" "#009E73" "#F0E442" "#0072B2" "#D55E00" "#CC79A7" #> [8] "#999999" "#000000" palette_okabe_ito(order = c(2, 3, 5), alpha = 0.9) #> [1] "#56B4E9E6" "#009E73E6" "#0072B2E6" palette_okabe_ito(order = c("bluishgreen", "yellow", "blue")) #> [1] "#009E73" "#F0E442" "#0072B2" ``` ``` -------------------------------- ### Customized ggplot2 Scatter Plot with Okabe-Ito Colors Source: https://malcolmbarrett.github.io/ggokabeito/index.html Applies scale_color_okabe_ito() to a scatter plot, customizing the legend title and alpha transparency. ```r ggplot(mpg, aes(cty, hwy, color = factor(cyl))) + geom_point(alpha = 0.7) + scale_color_okabe_ito(name = "Cylinders", alpha = .9) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.