sp_manual_color_ggplot2: Add manual color assignment for both categorical and...

sp_manual_color_ggplot2R Documentation

Add manual color assignment for both categorical and numerical variable

Description

Add manual color assignment for both categorical and numerical variable

Usage

sp_manual_color_ggplot2(
  p,
  data,
  color_variable,
  manual_color_vector = NULL,
  alpha = 1
)

Arguments

p

A ggplot2 object

data

Data matrix used for the ggplot2 object p

color_variable

Name of columns for color assignment

manual_color_vector

Manually set colors for each geom. Default NULL, meaning using ggplot2 default. Colors like c('red', 'blue', '#6181BD') (number of colors not matter) or a RColorBrewer color set like "BrBG" "PiYG" "PRGn" "PuOr" "RdBu" "RdGy" "RdYlBu" "RdYlGn" "Spectral" "Accent" "Dark2" "Paired" "Pastel1" "Pastel2" "Set1" "Set2" "Set3" "Blues" "BuGn" "BuPu" "GnBu" "Greens" "Greys" "Oranges" "OrRd" "PuBu" "PuBuGn" "PuRd" "Purples" "RdPu" "Reds" "YlGn" "YlGnBu" "YlOrBr" "YlOrRd" (check http://www.sthda.com/english/wiki/colors-in-r for more).

alpha

Color transparency (0-1). 0: opaque; 1: transparent.

Value

A ggplot2 object

Examples


## Not run:
p <- sp_manual_color_ggplot2(p, data, color_variable, manual_color_vector)

## End(Not run)


Tong-Chen/ImageGP documentation built on April 14, 2025, 12:54 p.m.