'Using Highchart for two panes candlesticks and column in R
I'm working with financial data and i want to reproduce same column plot with two colors in to panes one for UP (green) and red for the down ones.
Below is my code.
library(highcharter)
library(quantmod)
#Retrieve stock data to plot.
aap1<-quantmod::getSymbols("AAPL",
src = "yahoo",
from = "2020-01-01",
auto.assign = FALSE)
colnames(aap1)<- c("Open", "High", "Low", "Close", "Volume", "Adjusted")
highchart (type="stock") %>%
hc_title(text = paste0("AAPL chart : from 2020-01-01 to ", Sys.Date())) %>%
hc_add_series (name = "Prices", aap1, yAxis = 0, showInLegend = FALSE) %>%
hc_add_yAxis (nid = 1L,
title = list(
style=list(color='#333333',
fontSize = "20px",
fontFamily= "Erica One"),
text = "Volume"), relative = 1)%>%
hc_add_series (name = "Volume", aap1[, "Volume"], yAxis = 1, type="column", showInLegend= FALSE, color="red")%>%
hc_add_yAxis (nid = 2L,
title = list(
style=list(color='#333333',
fontSize = "20px",
fontFamily= "Erica One"),
text = "Volume"), relative = 1)%>%
hc_exporting(
enabled = TRUE, # always enabled,
filename = paste0("AAPL chart : from 2020-01-01 to ", Sys.Date())
)
This picture shows what I'm getting
but what I'm expecting should look like this
green for UP and red for down for example
All the code I'm finding are not what I'm looking for and they are also in JS and I don't know how to exactly deal with it (turn them in R code).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
