4

Using version.string R version 2.11.0 (2010-04-22) quantmod "0.3-17"
Windows XP

When using the chartSeries function in quantmod with type="line" the line color that is displayed on the chart is green. I would like to change the color from green to another color.

It looks like i can change the chartTheme, but the theme does not explicitly have a variable to change the color of the plot display for lines.

I can change the line display color when using the plot() function - So is it possible to change the display of line plots to a different color using chartSeries() in quantmod?

Andrie
  • 176,377
  • 47
  • 447
  • 496
tuffgoat
  • 43
  • 1
  • 3
  • another way to do this is to `setDefaults(chartSeries, up.col="gold")`. That way you don't have to keep calling `chartSeries( ..., theme = chartTheme(up.col='gold') )` with each call to `chartSeries`. – isomorphismes Jul 25 '13 at 20:01

1 Answers1

2

Rather than cluttering its argument list with options controlling all aspects of chart appearance, chartSeries() has a single theme argument. theme accepts a chart.theme object that controls the colors of most parts of the plot, bundling all of those color choices into a single object.

The function chartTheme() creates chart.theme objects of the appropriate form. Among the options listed in ?chartTheme, up.col seems to control the color you are asking about:

require(quantmod)
getSymbols("YHOO")
chartSeries(YHOO, type="line",
            theme = chartTheme("black", up.col='gold'))

enter image description here

Josh O'Brien
  • 159,210
  • 26
  • 366
  • 455
  • Thanks! - that did the job - I thought the up.col dn.col were only for the matchstick and candle stick colors- once you know the answer its easy - Thanks!! Tuffgoat – tuffgoat Nov 05 '11 at 19:47