joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
794 stars 219 forks source link

how to set color in multiple graphs in one window #385

Open mytarmail opened 1 year ago

mytarmail commented 1 year ago

Description

I want to paint several graphs in different colors in one window so that it is convenient to distinguish them question reposted here

Expected behavior

I want each graph to have its own color, ideally i want to have access to the main graphics settings of each chart

Minimal, reproducible example

library(quantmod)
library(xts)

len <- 20000

times <- seq(as.POSIXct("2016-01-01 00:00:00"), length = len, by = "sec")

S1 <- as.xts(cumsum(rnorm(len)),order.by = times)
S1 <- to.period(S1,period = "minutes",k = 5,indexAt = 'startof')

S2 <- as.xts(cumsum(rnorm(len)),order.by = times)
S2 <- to.period(S2,period = "minutes",k = 5,indexAt = 'startof')

S3 <- as.xts(cumsum(rnorm(len)),order.by = times)
S3 <- to.period(S3,period = "minutes",k = 5,indexAt = 'startof')

chart_Series(S1)
add_Series(S2,on = 1)
add_Series(S3,on = 1)

Session Info

sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

time zone: Europe/Kiev
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4.22 TTR_0.24.3      xts_0.13.1      zoo_1.8-12     
[5] mt5R_0.1.5

loaded via a namespace (and not attached):
[1] zoo_1.8-12     compiler_4.3.0 tools_4.3.0    xts_0.13.1     curl_5.0.0    
[6] mt5R_0.1.5     grid_4.3.0     TTR_0.24.3     lattice_0.21-8