The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Advanced Color Palette Management

library(evanverse)
library(ggplot2)
library(dplyr)

🎨 Mastering Color Palettes in evanverse

The evanverse package provides a sophisticated color palette system designed specifically for data visualization and bioinformatics applications. This guide explores the complete palette ecosystem, from basic usage to advanced customization.

🎯 Overview of the Palette System

The evanverse palette system includes:

📋 Discovering Available Palettes

List All Palettes by Type

# Get all available palettes by type
seq_palettes <- list_palettes(type = "sequential")
#> 
#> ── Available Color Palettes ────────────────────────────────────────────────────
#> ℹ Total palettes: 5
#> ℹ Type "sequential": 5 palettes
#> ℹ \u2022 blues (sequential) - 3 colors
#> ℹ \u2022 forest_fade (sequential) - 4 colors
#> ℹ \u2022 muted_gradient (sequential) - 4 colors
#> ℹ \u2022 warm_blush (sequential) - 4 colors
#> ℹ \u2022 ggsci_locuszoom (sequential) - 7 colors
qual_palettes <- list_palettes(type = "qualitative")
#> 
#> ── Available Color Palettes ────────────────────────────────────────────────────
#> ℹ Total palettes: 23
#> ℹ Type "qualitative": 23 palettes
#> ℹ \u2022 earthy_triad (qualitative) - 3 colors
#> ℹ \u2022 primary_triad (qualitative) - 3 colors
#> ℹ \u2022 softtrio (qualitative) - 3 colors
#> ℹ \u2022 vintage_triad (qualitative) - 3 colors
#> ℹ \u2022 balanced_quartet (qualitative) - 4 colors
#> ℹ \u2022 vibrant (qualitative) - 5 colors
#> ℹ \u2022 violin (qualitative) - 5 colors
#> ℹ \u2022 harmonysix (qualitative) - 6 colors
#> ℹ \u2022 pastel_harmony (qualitative) - 6 colors
#> ℹ \u2022 ggsci_jama (qualitative) - 7 colors
#> ℹ \u2022 ggsci_tron_legacy (qualitative) - 7 colors
#> ℹ \u2022 ggsci_nejm (qualitative) - 8 colors
#> ℹ \u2022 rcb_set2 (qualitative) - 8 colors
#> ℹ \u2022 ggsci_lancet (qualitative) - 9 colors
#> ℹ \u2022 rcb_set1 (qualitative) - 9 colors
#> ℹ \u2022 vividset (qualitative) - 9 colors
#> ℹ \u2022 ggsci_cosmic (qualitative) - 10 colors
#> ℹ \u2022 ggsci_flatui (qualitative) - 10 colors
#> ℹ \u2022 ggsci_jco (qualitative) - 10 colors
#> ℹ \u2022 ggsci_npg (qualitative) - 10 colors
#> ℹ \u2022 ggsci_futurama (qualitative) - 12 colors
#> ℹ \u2022 rcb_set3 (qualitative) - 12 colors
#> ℹ \u2022 sc_pbmc (qualitative) - 17 colors
div_palettes <- list_palettes(type = "diverging")
#> 
#> ── Available Color Palettes ────────────────────────────────────────────────────
#> ℹ Total palettes: 7
#> ℹ Type "diverging": 7 palettes
#> ℹ \u2022 contrast_duo (diverging) - 2 colors
#> ℹ \u2022 fire_ice_duo (diverging) - 2 colors
#> ℹ \u2022 polar_duo (diverging) - 2 colors
#> ℹ \u2022 sunset_sky (diverging) - 2 colors
#> ℹ \u2022 piyg (diverging) - 3 colors
#> ℹ \u2022 earthy_diverge (diverging) - 5 colors
#> ℹ \u2022 gradient_rd_bu (diverging) - 11 colors

cat("📈 Sequential Palettes (", length(seq_palettes), "):\n")
#> 📈 Sequential Palettes ( 4 ):
cat(paste(seq_palettes, collapse = ", "), "\n\n")
#> c("blues", "forest_fade", "muted_gradient", "warm_blush", "ggsci_locuszoom"), c("sequential", "sequential", "sequential", "sequential", "sequential"), c(3, 4, 4, 4, 7), list(c("#deebf7", "#9ecae1", "#3182bd"), c("#B2C9AD", "#91AC8F", "#66785F", "#4B5945"), c("#E2E0C8", "#A7B49E", "#818C78", "#5C7285"), c("#FFCDB2", "#FFB4A2", "#E5989B", "#B5828C"), c("#D43F3A", "#EEA236", "#5CB85C", "#46B8DA", "#357EBD", "#9632B8", "#B8B8B8"))

cat("🏷️ Qualitative Palettes (", length(qual_palettes), "):\n")
#> 🏷️ Qualitative Palettes ( 4 ):
cat(paste(qual_palettes, collapse = ", "), "\n\n")
#> c("earthy_triad", "primary_triad", "softtrio", "vintage_triad", "balanced_quartet", "vibrant", "violin", "harmonysix", "pastel_harmony", "ggsci_jama", "ggsci_tron_legacy", "ggsci_nejm", "rcb_set2", "ggsci_lancet", "rcb_set1", "vividset", "ggsci_cosmic", "ggsci_flatui", "ggsci_jco", "ggsci_npg", "ggsci_futurama", "rcb_set3", "sc_pbmc"), c("qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative", "qualitative"), c(3, 3, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 12, 12, 17), list(c("#C64328", "#56BBA5", "#E3A727"), c("#C64328", "#2AA6C6", "#E3A727"), c("#E64B35B2", "#00A087B2", "#3C5488B2"), c("#96A0D9", "#D9BDAD", "#D9D5A0"), c("#5D83B4", "#9FD0E8", "#CDAE9D", "#959683"), c("#BF3F9D", "#B3BCD7", "#6DA6A0", "#D98A29", "#F2C894"), c("#37848C", "#F2935C", "#F2A88D", "#D95555", "#A7CAE9"), c("#BF3641", "#836AA6", "#377BA6", "#448C42", "#D96236", "#B79290"), c("#B2AA76", "#8C91CF", "#D7D79C", "#DABFAC", "#BCEDDB", "#C380A0"), c("#374E55", "#DF8F44", "#00A1D5", "#B24745", 
#> "#79AF97", "#6A6599", "#80796B"), c("#FF410D", "#6EE2FF", "#F7C530", "#95CC5E", "#D0DFE6", "#F79D1E", "#748AA6"), c("#BC3C29", "#0072B5", "#E18727", "#20854E", "#7876B1", "#6F99AD", "#FFDC91", "#EE4C97"), c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F", "#E5C494", "#B3B3B3"), c("#00468B", "#ED0000", "#42B540", "#0099B4", "#925E9F", "#FDAF91", "#AD002A", "#ADB6B6", "#1B1919"), c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"), c("#E64B35", 
#> "#4DBBD5", "#00A087", "#3C5488", "#F39B7F", "#8491B4", "#91D1C2", "#DC0000", "#7E6148"), c("#2E2A2B", "#CF4E9C", "#8C57A2", "#358DB9", "#82581F", "#2F509E", "#E5614C", "#97A1A7", "#3DA873", "#DC9445"), c("#c0392b", "#d35400", "#f39c12", "#27ae60", "#16a085", "#2980b9", "#8e44ad", "#2c3e50", "#7f8c8d", "#bdc3c7"), c("#0073C2", "#EFC000", "#868686", "#CD534C", "#7AA6DC", "#003C67", "#8F7700", "#3B3B3B", "#A73030", "#4A6990"), c("#E64B35", "#4DBBD5", "#00A087", "#3C5488", "#F39B7F", "#8491B4", "#91D1C2", 
#> "#DC0000", "#7E6148", "#B09C85"), c("#FF6F00", "#C71000", "#008EA0", "#8A4198", "#5A9599", "#FF6348", "#84D7E1", "#FF95A8", "#3D3B25", "#ADE2D0", "#1A5354", "#3F4041"), c("#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3", "#FDB462", "#B3DE69", "#FCCDE5", "#D9D9D9", "#BC80BD", "#CCEBC5", "#FFED6F"), c("#a2d2e7", "#67a8cd", "#ffc17f", "#cf9f88", "#6fb3a8", "#b3e19b", "#50aa4b", "#ff9d9f", "#f36569", "#3581b7", "#cdb6da", "#704ba3", "#9a7fbd", "#dba9a8", "#e40300", "#e99b78", "#ff8831"))

cat("↔️ Diverging Palettes (", length(div_palettes), "):\n")
#> ↔️ Diverging Palettes ( 4 ):
cat(paste(div_palettes, collapse = ", "), "\n")
#> c("contrast_duo", "fire_ice_duo", "polar_duo", "sunset_sky", "piyg", "earthy_diverge", "gradient_rd_bu"), c("diverging", "diverging", "diverging", "diverging", "diverging", "diverging", "diverging"), c(2, 2, 2, 2, 3, 5, 11), list(c("#C64328", "#56BBA5"), c("#2AA6C6", "#C64328"), c("#8CB5D2", "#E18E8F"), c("#57A2FF", "#FF8000"), c("#E64B35B2", "#00A087B2", "#3C5488B2"), c("#283618", "#606C38", "#FEFAE0", "#DDA15E", "#BC6C25"), c("#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#f7f7f7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"))

🔍 Working with Individual Palettes

Getting Specific Palettes

# Get qualitative palette with default number of colors
vivid_default <- get_palette("vividset", type = "qualitative")
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors
cat("Vivid palette (default):\n")
#> Vivid palette (default):
print(vivid_default)
#> [1] "#E64B35" "#4DBBD5" "#00A087" "#3C5488" "#F39B7F" "#8491B4" "#91D1C2"
#> [8] "#DC0000" "#7E6148"

# Get specific number of colors from sequential palette
blues_3 <- get_palette("blues", type = "sequential", n = 3)
#> ✔ Loaded palette "blues" ("sequential"), 3 colors
cat("\nBlues palette (3 colors):\n")
#> 
#> Blues palette (3 colors):
print(blues_3)
#> [1] "#deebf7" "#9ecae1" "#3182bd"

# Get all available colors from a palette (just omit n parameter)
blues_all <- get_palette("blues", type = "sequential")
#> ✔ Loaded palette "blues" ("sequential"), 3 colors
cat("\nBlues palette (all", length(blues_all), "colors):\n")
#> 
#> Blues palette (all 3 colors):
print(blues_all)
#> [1] "#deebf7" "#9ecae1" "#3182bd"

Preview Individual Palettes

# Save current par settings
oldpar <- par(no.readonly = TRUE)

# Preview different palette types
par(mfrow = c(2, 2), mar = c(3, 1, 2, 1))

# Qualitative palette preview
preview_palette("vividset", type = "qualitative")
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors
#> 
#> ── Previewing palette: "vividset" ──
#> 
#> ℹ Plot type: "bar", colors: 9
title("Qualitative: VividSet", cex.main = 1.2, col.main = "#0D47A1")

# Sequential palette preview
preview_palette("blues", type = "sequential")
#> ✔ Loaded palette "blues" ("sequential"), 3 colors
#> 
#> ── Previewing palette: "blues" ──
#> 
#> ℹ Plot type: "bar", colors: 3
title("Sequential: Blues", cex.main = 1.2, col.main = "#0D47A1")

# Another sequential palette
preview_palette("warm_blush", type = "sequential")
#> ✔ Loaded palette "warm_blush" ("sequential"), 4 colors
#> 
#> ── Previewing palette: "warm_blush" ──
#> 
#> ℹ Plot type: "bar", colors: 4
title("Sequential: Warm Blush", cex.main = 1.2, col.main = "#0D47A1")

# Diverging palette preview
preview_palette("gradient_rd_bu", type = "diverging")
#> ✔ Loaded palette "gradient_rd_bu" ("diverging"), 11 colors
#> 
#> ── Previewing palette: "gradient_rd_bu" ──
#> 
#> ℹ Plot type: "bar", colors: 11
title("Diverging: Red-Blue Gradient", cex.main = 1.2, col.main = "#0D47A1")
Preview of different palette types with color swatches

Preview of different palette types with color swatches


# Restore previous par settings
par(oldpar)

🛠️ Creating Custom Palettes

Basic Custom Palette Creation

# Define custom color schemes
modern_colors <- c("#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEAA7")
nature_colors <- c("#2E7D32", "#66BB6A", "#A5D6A7", "#E8F5E8")
corporate_colors <- c("#0D47A1", "#1976D2", "#42A5F5", "#90CAF9", "#E3F2FD")

# Create custom palettes (Note: this would save to package directory)
# create_palette("modern_vivid", type = "qualitative", colors = modern_colors)
# create_palette("nature_gradient", type = "sequential", colors = nature_colors)
# create_palette("corporate_blue", type = "sequential", colors = corporate_colors)

cat("Custom palette examples:\n")
#> Custom palette examples:
cat("Modern vivid:", paste(modern_colors, collapse = ", "), "\n")
#> Modern vivid: #FF6B6B, #4ECDC4, #45B7D1, #96CEB4, #FFEAA7
cat("Nature gradient:", paste(nature_colors, collapse = ", "), "\n")
#> Nature gradient: #2E7D32, #66BB6A, #A5D6A7, #E8F5E8
cat("Corporate blue:", paste(corporate_colors, collapse = ", "), "\n")
#> Corporate blue: #0D47A1, #1976D2, #42A5F5, #90CAF9, #E3F2FD

Color Space Utilities

# Convert between HEX and RGB formats
hex_colors <- c("#FF6B6B", "#4ECDC4", "#45B7D1")

# HEX to RGB conversion
rgb_matrix <- hex2rgb(hex_colors)
#> ✔ Converted 3 HEX values to RGB.
#> ℹ #FF6B6B -> RGB: c(255, 107, 107)
#> ℹ #4ECDC4 -> RGB: c(78, 205, 196)
#> ℹ #45B7D1 -> RGB: c(69, 183, 209)
cat("HEX to RGB conversion:\n")
#> HEX to RGB conversion:
print(rgb_matrix)
#> $`#FF6B6B`
#>   r   g   b 
#> 255 107 107 
#> 
#> $`#4ECDC4`
#>   r   g   b 
#>  78 205 196 
#> 
#> $`#45B7D1`
#>   r   g   b 
#>  69 183 209

# RGB back to HEX conversion
hex_back <- rgb2hex(rgb_matrix)
#> ✔ Converted 3 RGB values to HEX.
#> ℹ RGB: c(255, 107, 107) → HEX: #FF6B6B
#> ℹ RGB: c(78, 205, 196) → HEX: #4ECDC4
#> ℹ RGB: c(69, 183, 209) → HEX: #45B7D1
cat("\nRGB back to HEX:\n")
#> 
#> RGB back to HEX:
print(hex_back)
#>   #FF6B6B   #4ECDC4   #45B7D1 
#> "#FF6B6B" "#4ECDC4" "#45B7D1"

# Verify round-trip conversion
cat("\nRound-trip verification:\n")
#> 
#> Round-trip verification:
print(data.frame(
  Original = hex_colors,
  Converted = hex_back,
  Match = hex_colors == hex_back
))
#>         Original Converted Match
#> #FF6B6B  #FF6B6B   #FF6B6B  TRUE
#> #4ECDC4  #4ECDC4   #4ECDC4  TRUE
#> #45B7D1  #45B7D1   #45B7D1  TRUE

📊 Practical Applications in Visualization

Qualitative Palettes for Categorical Data

# Sample categorical data
set.seed(123)
category_data <- data.frame(
  Group = rep(LETTERS[1:5], each = 20),
  Value = c(rnorm(20, 10, 2), rnorm(20, 15, 3), rnorm(20, 12, 2.5),
            rnorm(20, 18, 4), rnorm(20, 8, 1.5)),
  Type = sample(c("Control", "Treatment"), 100, replace = TRUE)
)

# Use qualitative palette for groups
qual_colors <- get_palette("vividset", type = "qualitative", n = 5)
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors

p1 <- ggplot(category_data, aes(x = Group, y = Value, fill = Group)) +
  geom_boxplot(alpha = 0.8, outlier.alpha = 0.6) +
  scale_fill_manual(values = qual_colors) +
  labs(
    title = "Qualitative Palette: Group Comparison",
    subtitle = "Using vividset palette for categorical data",
    x = "Experimental Group",
    y = "Measured Value"
  ) +
  theme_minimal() +
  theme(
    legend.position = "none",
    plot.title = element_text(size = 14, face = "bold", color = "#0D47A1"),
    plot.subtitle = element_text(size = 11, color = "#666666")
  )

print(p1)
Demonstration of qualitative palettes for categorical data visualization

Demonstration of qualitative palettes for categorical data visualization

Sequential Palettes for Continuous Data

# Generate correlation matrix data
set.seed(456)
vars <- paste0("Var", 1:8)
cor_matrix <- cor(matrix(rnorm(8 * 50), ncol = 8))
colnames(cor_matrix) <- rownames(cor_matrix) <- vars

# Convert to long format for ggplot
cor_long <- expand.grid(X = vars, Y = vars)
cor_long$Correlation <- as.vector(cor_matrix)

# Use sequential palette
seq_colors <- get_palette("ggsci_locuszoom", type = "sequential", n = 7)
#> ✔ Loaded palette "ggsci_locuszoom" ("sequential"), 7 colors

p2 <- ggplot(cor_long, aes(x = X, y = Y, fill = Correlation)) +
  geom_tile(color = "white", size = 0.5) +
  scale_fill_gradientn(
    colors = seq_colors,
    name = "Correlation",
    limits = c(-1, 1),
    breaks = seq(-1, 1, 0.5),
    labels = c("-1.0", "-0.5", "0.0", "0.5", "1.0")
  ) +
  labs(
    title = "Sequential Palette: Correlation Heatmap",
    subtitle = "Using ggsci_locuszoom palette for continuous correlation data",
    x = "Variables",
    y = "Variables"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1),
    plot.title = element_text(size = 14, face = "bold", color = "#0D47A1"),
    plot.subtitle = element_text(size = 11, color = "#666666"),
    panel.grid = element_blank()
  ) +
  coord_fixed()

print(p2)
Sequential palette demonstration with heatmap-style visualization

Sequential palette demonstration with heatmap-style visualization

Diverging Palettes for Centered Data

# Generate data with meaningful center (e.g., fold changes)
set.seed(789)
gene_data <- data.frame(
  Gene = paste0("Gene_", 1:25),
  LogFoldChange = rnorm(25, 0, 1.5),
  Sample = rep(paste0("Sample_", 1:5), each = 5)
)

# Use diverging palette
div_colors <- get_palette("gradient_rd_bu", type = "diverging", n = 11)
#> ✔ Loaded palette "gradient_rd_bu" ("diverging"), 11 colors

p3 <- ggplot(gene_data, aes(x = Sample, y = Gene, fill = LogFoldChange)) +
  geom_tile(color = "white", size = 0.3) +
  scale_fill_gradientn(
    colors = div_colors,
    name = "Log2 FC",
    limits = c(-3, 3),
    breaks = seq(-3, 3, 1.5),
    labels = c("-3", "-1.5", "0", "+1.5", "+3")
  ) +
  labs(
    title = "Diverging Palette: Gene Expression Changes",
    subtitle = "Using red-blue palette for fold change data (centered at 0)",
    x = "Sample",
    y = "Gene"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(size = 14, face = "bold", color = "#0D47A1"),
    plot.subtitle = element_text(size = 11, color = "#666666"),
    panel.grid = element_blank(),
    axis.text.y = element_text(size = 8)
  )

print(p3)
Diverging palette showing data with meaningful center point

Diverging palette showing data with meaningful center point

🔬 Bioinformatics-Specific Applications

Palette Selection Guidelines

cat("🧬 BIOINFORMATICS PALETTE GUIDELINES\n")
#> 🧬 BIOINFORMATICS PALETTE GUIDELINES
cat("=====================================\n\n")
#> =====================================

cat("📊 For Gene Expression Data:\n")
#> 📊 For Gene Expression Data:
cat("  • Sequential: Use 'blues', 'greens', or 'oranges'\n")
#>   • Sequential: Use 'blues', 'greens', or 'oranges'
cat("  • Diverging: Use 'gradient_rd_bu' or 'earthy_diverge' for fold changes\n\n")
#>   • Diverging: Use 'gradient_rd_bu' or 'earthy_diverge' for fold changes

cat("🔬 For Pathway Analysis:\n")
#> 🔬 For Pathway Analysis:
cat("  • Qualitative: Use 'vividset' or 'softpastel' for pathways\n")
#>   • Qualitative: Use 'vividset' or 'softpastel' for pathways
cat("  • Sequential: Use 'purples' for p-value gradients\n\n")
#>   • Sequential: Use 'purples' for p-value gradients

cat("🎯 For Multi-omics Data:\n")
#> 🎯 For Multi-omics Data:
cat("  • Qualitative: Use 'brightcontrast' for distinct data types\n")
#>   • Qualitative: Use 'brightcontrast' for distinct data types
cat("  • Avoid red/green combinations for colorblind accessibility\n\n")
#>   • Avoid red/green combinations for colorblind accessibility

cat("📈 For Time Course Data:\n")
#> 📈 For Time Course Data:
cat("  • Sequential: Use 'blues' or 'teals' for temporal progression\n")
#>   • Sequential: Use 'blues' or 'teals' for temporal progression
cat("  • Qualitative: Use 'vividset' for treatment groups\n")
#>   • Qualitative: Use 'vividset' for treatment groups

Example: Multi-omics Visualization

# Simulate multi-omics data
set.seed(321)
multiomics_data <- data.frame(
  Sample = rep(paste0("Patient_", 1:12), each = 4),
  DataType = rep(c("RNA-seq", "Proteomics", "Metabolomics", "Methylation"), 12),
  Intensity = c(
    rnorm(12, 100, 20),  # RNA-seq
    rnorm(12, 50, 15),   # Proteomics
    rnorm(12, 25, 8),    # Metabolomics
    rnorm(12, 75, 12)    # Methylation
  ),
  Condition = rep(rep(c("Control", "Disease"), each = 6), 4)
)

# Use distinct qualitative palette for data types
omics_colors <- get_palette("vividset", type = "qualitative", n = 4)
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors
names(omics_colors) <- c("RNA-seq", "Proteomics", "Metabolomics", "Methylation")

p4 <- ggplot(multiomics_data, aes(x = Sample, y = Intensity, fill = DataType)) +
  geom_bar(stat = "identity", position = "dodge", alpha = 0.8) +
  scale_fill_manual(values = omics_colors, name = "Data Type") +
  facet_wrap(~Condition, scales = "free_x") +
  labs(
    title = "Multi-omics Data Integration",
    subtitle = "Using qualitative palette to distinguish data types",
    x = "Patient Samples",
    y = "Normalized Intensity"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1, size = 8),
    plot.title = element_text(size = 14, face = "bold", color = "#0D47A1"),
    plot.subtitle = element_text(size = 11, color = "#666666"),
    legend.position = "bottom",
    strip.background = element_rect(fill = "#E3F2FD", color = NA)
  )

print(p4)
Multi-omics data visualization using appropriate color palettes

Multi-omics data visualization using appropriate color palettes

🎨 Advanced Palette Techniques

Palette Interpolation and Blending

# Create custom gradient using palette interpolation
base_colors <- get_palette("vividset", type = "qualitative", n = 3)
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors

# Manual interpolation demonstration
custom_gradient <- colorRampPalette(base_colors[1:2])(10)

# Create visualization showing interpolation
gradient_demo <- data.frame(
  x = 1:10,
  y = rep(1, 10),
  color = custom_gradient
)

p5 <- ggplot(gradient_demo, aes(x = x, y = y, fill = color)) +
  geom_tile(height = 0.5, width = 0.9) +
  scale_fill_identity() +
  labs(
    title = "Custom Color Interpolation",
    subtitle = "Creating gradients from qualitative palette colors",
    x = "Gradient Position",
    y = ""
  ) +
  theme_minimal() +
  theme(
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank(),
    panel.grid = element_blank(),
    plot.title = element_text(size = 14, face = "bold", color = "#0D47A1"),
    plot.subtitle = element_text(size = 11, color = "#666666")
  )

print(p5)
Advanced color techniques: interpolation and custom gradients

Advanced color techniques: interpolation and custom gradients


# Display the gradient colors
cat("Custom gradient colors:\n")
#> Custom gradient colors:
print(custom_gradient)
#>  [1] "#E64B35" "#D55746" "#C36358" "#B3706A" "#A27C7C" "#91898D" "#80959F"
#>  [8] "#6FA2B1" "#5DAEC3" "#4DBBD5"

📋 Best Practices and Recommendations

Accessibility Considerations

cat("♿ ACCESSIBILITY & BEST PRACTICES\n")
#> ♿ ACCESSIBILITY & BEST PRACTICES
cat("================================\n\n")
#> ================================

cat("🌈 Color Vision Considerations:\n")
#> 🌈 Color Vision Considerations:
cat("  • Test palettes with colorblind simulators\n")
#>   • Test palettes with colorblind simulators
cat("  • Avoid relying solely on red/green distinctions\n")
#>   • Avoid relying solely on red/green distinctions
cat("  • Use high contrast ratios (minimum 3:1)\n")
#>   • Use high contrast ratios (minimum 3:1)
cat("  • Consider texture/pattern alternatives\n\n")
#>   • Consider texture/pattern alternatives

cat("📱 Multi-Platform Compatibility:\n")
#> 📱 Multi-Platform Compatibility:
cat("  • Test on different displays (mobile, print, projector)\n")
#>   • Test on different displays (mobile, print, projector)
cat("  • Use sufficient color separation for small elements\n")
#>   • Use sufficient color separation for small elements
cat("  • Consider grayscale conversion compatibility\n\n")
#>   • Consider grayscale conversion compatibility

cat("📊 Data Visualization Guidelines:\n")
#> 📊 Data Visualization Guidelines:
cat("  • Match palette type to data type (sequential/categorical)\n")
#>   • Match palette type to data type (sequential/categorical)
cat("  • Limit qualitative palettes to 8-10 distinct categories\n")
#>   • Limit qualitative palettes to 8-10 distinct categories
cat("  • Use consistent color meaning across related plots\n")
#>   • Use consistent color meaning across related plots
cat("  • Reserve bright colors for important data points\n")
#>   • Reserve bright colors for important data points

Performance Optimization

cat("⚡ PERFORMANCE OPTIMIZATION TIPS\n")
#> ⚡ PERFORMANCE OPTIMIZATION TIPS
cat("===============================\n\n")
#> ===============================

cat("🚀 Efficient Palette Usage:\n")
#> 🚀 Efficient Palette Usage:
cat("  • Cache frequently used palettes in variables\n")
#>   • Cache frequently used palettes in variables
cat("  • Use specific n= parameter to avoid unused colors\n")
#>   • Use specific n= parameter to avoid unused colors
cat("  • Pre-compile custom palettes for repeated use\n\n")
#>   • Pre-compile custom palettes for repeated use

# Demonstrate efficient palette caching
cat("Example of efficient palette caching:\n")
#> Example of efficient palette caching:
cat("# Good: Cache palette once\n")
#> # Good: Cache palette once
cat("my_colors <- get_palette('vividset', type = 'qualitative', n = 5)\n")
#> my_colors <- get_palette('vividset', type = 'qualitative', n = 5)
cat("# Then reuse: scale_fill_manual(values = my_colors)\n\n")
#> # Then reuse: scale_fill_manual(values = my_colors)

cat("# Avoid: Repeated palette calls\n")
#> # Avoid: Repeated palette calls
cat("# scale_fill_manual(values = get_palette('vividset', ...))\n")
#> # scale_fill_manual(values = get_palette('vividset', ...))

🔧 Troubleshooting Common Issues

Common Problems and Solutions

cat("🛠️ TROUBLESHOOTING GUIDE\n")
#> 🛠️ TROUBLESHOOTING GUIDE
cat("=======================\n\n")
#> =======================

cat("❌ Issue: 'Palette not found' error\n")
#> ❌ Issue: 'Palette not found' error
cat("✅ Solution: Check available palettes with list_palettes()\n\n")
#> ✅ Solution: Check available palettes with list_palettes()

cat("❌ Issue: Not enough colors in palette\n")
#> ❌ Issue: Not enough colors in palette
cat("✅ Solution: Use n='all' or choose different palette\n\n")
#> ✅ Solution: Use n='all' or choose different palette

cat("❌ Issue: Colors don't match expected output\n")
#> ❌ Issue: Colors don't match expected output
cat("✅ Solution: Verify palette type (sequential/qualitative/diverging)\n\n")
#> ✅ Solution: Verify palette type (sequential/qualitative/diverging)

cat("❌ Issue: Custom palette not saving\n")
#> ❌ Issue: Custom palette not saving
cat("✅ Solution: Check write permissions and file paths\n\n")
#> ✅ Solution: Check write permissions and file paths

# Demonstrate error handling
tryCatch({
  # This will work
  valid_palette <- get_palette("vividset", type = "qualitative", n = 3)
  cat("✅ Successfully retrieved vividset palette\n")
}, error = function(e) {
  cat("❌ Error:", e$message, "\n")
})
#> ✔ Loaded palette "vividset" ("qualitative"), 9 colors
#> ✅ Successfully retrieved vividset palette

tryCatch({
  # This might fail if palette doesn't exist
  invalid_palette <- get_palette("nonexistent", type = "qualitative")
  cat("✅ Retrieved nonexistent palette\n")
}, error = function(e) {
  cat("❌ Expected error for nonexistent palette:", e$message, "\n")
})
#> ❌ Expected error for nonexistent palette: Palette "nonexistent" not found in any type.

🎯 Summary and Next Steps

The evanverse color palette system provides:

Comprehensive palette collection with 15+ carefully curated palettes ✅ Type-specific organization (sequential, qualitative, diverging) ✅ Flexible color extraction with custom counts and interpolation ✅ Bio-focused design optimized for scientific visualization ✅ Easy customization with palette creation and modification tools ✅ Professional quality suitable for publications and presentations

Continue Learning:

Quick Reference:

# Essential color palette functions
list_palettes(type = "sequential")          # List available palettes
get_palette("blues", type = "sequential")   # Get specific palette
preview_palette("vividset", "qualitative")  # Preview colors
bio_palette_gallery()                       # Show all palettes
hex2rgb("#FF6B6B")                         # Convert colors
create_palette("custom", colors = c(...))   # Create custom palette

🎨 Master the art of color with evanverse palettes!

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.