[R-SIG-Finance] Custom colour on the plot background using chartSeries()
Andre Luiz Tietbohl Ramos
@ndre|tr@mo@ @end|ng |rom gm@||@com
Mon Dec 8 12:36:35 CET 2025
Hello,
I'm trying to get a custom colour on a plot background to no avail.
I also tried via custom theme and via the rect function described below.
myTheme <- chart_theme()
myTheme$col$bg <- "#6C7B8B" ## "slategray4" or
myTheme$panel.background$fill <- "slategray4"
## Via set plot region color
rect(
par("usr")[1],
par("usr")[3],
par("usr")[2],
par("usr")[4],
col = "slategray4"
)
The solution below keeps the actual plot with white background for only its
borders have the desired colour,
chartSeries(PETR4.SA,
theme = chartTheme('white', up.col = 'darkgreen',
bg.col = "darkgray"),
par(lwd = 2),
type = "line",
bar.type = "hlc",
major.ticks='months',
minor.ticks=TRUE,
show.grid = TRUE,
TA = NULL
) + theme(plot.background = element_rect(fill =
"darkgray", color = "darkgray", size = 2))
Suggestions? Any help greatly appreciated.
Best,
--
Andre Luiz Tietbohl Ramos, PhD
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list