how to change color of highcharter candlestick stockchart?
I am trying to build a candlestick chart with quantmod and highcharter package. Building the chart is super easy.
library(quantmod)
library(highcharter)
x <- getSymbols("GOOG", auto.assign = FALSE)
highchart(type = "stock") %>%
hc_add_series(x)
The code above produces this chart:
I want to change the colors of the candlesticks. I want the upward changes to be in green and the downward changes to be red. I add a color argument to the hc_add_series
as hc_add_series(x, color = c("green", "red"))
, all the candlesticks become white. But if I provide only one color, hc_add_series(x, color = "red")
, the downward changes becomes red. But I couldn't find a way to change the color of the upward changes.
Does anyone have a solution for this?
Found the solution. I need to use the upColor
argument.
library(quantmod)
library(highcharter)
x <- getSymbols("GOOG", auto.assign = FALSE)
highchart(type = "stock") %>%
hc_add_series(x, upColor = "green", color = "red")
This would be the solution.