Search code examples
rchartsquantmod

Set Quantmod chartSeries line color from green to another color


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?


Solution

  • 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