Analysis in R: “KaradaColor” package, a color palette of KARADA-GOOD

RAnalytics

This is the color palette of “Good for the Body”. The color palette consists of five colors selected from photographs taken of Japanese landscapes and food. Plan to add more color palettes as they become available.

It also includes a color palette available in the ggplot2 package and commands to create complementary and triad colors for a given color.

version 0.1.5 was also released in CRAN on 23.04.21

CRAN - Package KaradaColor

GituHub

GitHub - KaradaGood/KaradaColor
ContributetoKaradaGood/KaradaColordevelopmentbycreatinganaccountonGitHub.

Note that the added color palette will be featured on Instagram with photos and color codes.

Instagram

Package version is 0.1.5. Checked with R version 4.2.3.

スポンサーリンク
Sponsored Link

Install Package

Run the following command.

#Install Package
install.packages("KaradaColor")

Example

See the command and package help for details.

#Loading the library
library("KaradaColor")

#Displaying the recorded color palette on the console: kg_show_console command
kg_show_console()

#Plot and color code displayed on console: kg_plot_color command
#Display the recorded color palette: name option
#Display with color: color option; if NULL, the name option takes precedence
#Show on console: showcode option; TRUE/FALSE
kg_plot_color("Kyoto_City", showcode = TRUE)
kg_plot_color(color = c("#ff48ac", "yellow"), showcode = TRUE)

#Create complementary color for specified color: kg_create_cc command
#Color specification: basecols option
#Transparency: alpha option
kg_create_cc(basecols = "yellow")
#          Base Complementary
#No_1 #FFFF00FF     #0000FFFF

#Combine with kg_plot_color command
kg_plot_color(color = kg_create_cc(basecols = "yellow"))
  
#Create triad color with specified color: kg_create_tc command
#Color specification: basecols option
#Transparency: alpha option
kg_create_tc(basecols = "green")
#      Triadic
#No_1 #FF0000FF
#No_2 #00FF00FF
#No_3 #0000FFFF

#Combine with kg_plot_color command
kg_plot_color(color = kg_create_tc(basecols = "green"))

###Commands available in the "ggplot2" package below
#scale_color_kg command/scale_fill_kg command
#Specify the name of the recorded color palette: name option
#Transparency: alpha option
#Color of missing value: na.value option
#For discrete values: discreate option; TRUE/FALSE

###データ例#####
if(!require("tidyverse", quietly = TRUE)){
  install.packages("tidyverse");require("tidyverse")
}
set.seed(1)
x <- LETTERS[1:20]
y <- paste0("var", seq(1,20))
data <- expand.grid(X=x, Y=y)
data$Z <- sample(c(NA, rnorm(15)), 20, replace = TRUE)
########

#continuous variables:
ggplot(data, aes(X, Y, fill= Z)) +
  geom_tile() +
  scale_fill_kg(discrete = FALSE, name = "Hanamushiro",
                alpha = 1, na.value = "red")

#discrete values:
library("ggplot2")
ggplot(data = diamonds, aes(x = cut, y = price,
                            color = cut, fill = cut)) +
  geom_boxplot() +
  scale_color_kg(name = "Hanamushiro", alpha = 0.3) +
  scale_fill_kg(name = "Hokkaido_Sky", alpha = 1) +
  theme_dark()

Output Example

・kg_show_console command

・kg_plot_color command

・kg_create_cc command

・kg_create_tc command


I hope this makes your analysis a little easier !!

タイトルとURLをコピーしました