Changing the col argument causing an error and how to store individual graphics parameters

I will try to determine the colors and fonts of my companies, etc. for all the schedules we do. So, the first question: how can I save them without overwriting the “normal” parameters? I mean, can I store everything in a "par-Container" and pass them to each plot, etc.

Here I defined the colors:

GRAPH_BLUE<-rgb(43/255, 71/255,153/255)
GRAPH_ORANGE<-rgb(243/255, 112/255, 33/255)
GRAPH_BACKGROUND<-rgb(180/255, 226/255, 244/255)

If I do plot(something, col=GRAPH_BLUE), I get the error:

Error in axis(1, at = xycoords$x, labels = FALSE, col = "#BBBBBB", ...) : 
  formal argument "col" matched by multiple actual arguments

If I do par(col=GRAPH_BLUE)and plot(something), it works exactly the way I want. Why is this? What do I need to change for it to work in the first line of code? As far as I understand, this causes an error, because there are several settings, starting with coland plot(something, col=GRAPH_BLUE)I overwrite them all and why the axis is not visible. But is there a special col setting only for the color line of the chart?

EDIT: Here's an example reproduced:

getSymbols('SPY', from='1998-01-01', to='2011-07-31', adjust=T)

GRAPH_BLUE<-rgb(43/255, 71/255,153/255)
GRAPH_ORANGE<-rgb(243/255, 112/255, 33/255)
GRAPH_BACKGROUND<-rgb(180/255, 226/255, 244/255)

par(col=GRAPH_BLUE)

plot.xts(SPY) #works great
plot.xts(SPY, col=GRAPH_ORANGE) #not really since all axes are missing

And the first question is, can I save all these settings not directly in par(), but in another variable that I pass to the chart function?

+4
source share
1 answer

col . par , bar.col candle.col. , , ? , ...

, par , .

op <- par(col=GRAPH_BLUE)
... ## some plot job
par(op) ## retsore it 

col . :

plot.xts.col <- function (old.parameters,lines.col='green', ...) {
.....
  ## you change this line to add the paremeter explicitly
  plot(xycoords$x, xycoords$y, type = type, axes = FALSE, 
   ann = FALSE,col=lines.col, ...)

 ## and the last line since .xtsEnv is an internal object
 assign(".plot.xts", recordPlot(), xts:::.xtsEnv)

}
+3

All Articles