set_constants: Maintain Colors

fg_update_aesR Documentation

Maintain Colors

Description

fg_update_aes() updates or replaces default aesthestics (e.g. colors, linestyles, etc). fg_update_line_colors() replaces line colors only fg_reset_to_default_state() resets colors and/or dates of interest fg_replace_theme() Replaces default theme used in static plots fg_verbose() Toggles printing of aesthetics

Usage

fg_update_aes(indta, aestype = NA_character_, persist = TRUE, replace = FALSE)

fg_update_line_colors(colorlist, replace = FALSE, persist = TRUE)

fg_replace_theme(newTheme, persist = TRUE)

fg_verbose(item = "")

fg_reset_to_default_state(reset = "all")

Arguments

indta

data.table aesthetic data.fram with columns as shown in details.

aestype

(Default: NA) character string with type of aesthetic requested. If not provided in ⁠[fg_Update_aes()]⁠ the

persist

(Default: TRUE) Keep changes across invocations of the package.

replace

(Default: FALSE) Replaces existing dates of interest with new set provided, otherwise replaces/inserts new rows only.

colorlist

List with up to 14 new colors just for line (series) coloring

newTheme

A new ggplot2 theme

item

(Default: "") A grep string for categories desired.

reset

(Default: "all"), options in ("all","colors","doi") to reset to defaults with the package.

Details

For colors, New data passed into fg_update_aes() persists across future loads of the package unless persist=FALSE. New color datasets must have at least three columns:

Column Meaning
category Arbitrary aestehtic category, e.g. "lines" for line colors.
variable Any string that can be sorted or grepped to map to data.
type Aesthetic type, in c("color","colorrange","linetype","symbol","alpha")
value String with value detired (e.g a color)

variable is used to prioritize colors, so (e.g. D01 will be the color of the first series in an input dataset)

If aestype=="colorrange" then a sequential scale of size n_max will be returned using details saved from fg_update_aes(). See scales::brewer_pal and colorbrewer

Value

No return value, as these are called for the side effects of adding to or replacing aesthetic sets.

See Also

fgts_dygraph(), fg_scatplot(), fg_get_aes()

Examples

# Data set, String
head(oldcolors <- fg_get_aes("lines"),3)
# then change as needed.  For example, to make the second line blue, and the 4th line red,
oldcolors[c(2,3),"value"] <- c("blue","tomato")
fg_update_aes( oldcolors )
head( fg_get_aes("lines"),3)
# to create a new category, make a similar `data.frame`, as in
newcolors <- data.frame(category=rep("mylines",3),variable=c("D01","D02","D03"),
                value=c("red","black","green"))
fg_update_aes( newcolors, aestype="color")
fg_get_aesstring("mylines")
#Theme replacement
require(ggplot2)
fg_replace_theme(ggplot2::theme_dark(),persist=FALSE)
fg_reset_to_default_state("all")


FinanceGraphs documentation built on March 29, 2026, 5:06 p.m.