Here is the code with data:
library(BatchGetSymbols) library(tidyverse) library(highcharter) t1 = BatchGetSymbols(c("MSFT", "SPY", "SH"))[[2]] t2 = t1[,c("ticker", "ref.date", "ret.adjusted.prices")] t3 = na.omit(pivot_wider(t2, names_from = ticker, values_from = "ret.adjusted.prices")) t4 = cor(t3[,2:4]) hchart(type = "heatmap", t4) %>% hc_legend(layout = "vertical", verticalAlign = "middle", align = "right") %>% hc_colorAxis(min = -1, max = 1, stops = color_stops(3, c("#d51f3a", "#FFFFFF", "#5daa45")))
Any help is appreciated!
What do you think about looping through all points, finding ones that have negative colorValue and then changing their color?
Like this demo: https://jsfiddle.net/BlackLabel/7p0ufcma
Then you could use the Highcharts JS API. You can see a handy article on how to do it here: https://www.highcharts.com/blog/tutorials/working-with-highcharts-javascript-syntax-in-r/?fbclid=IwAR3UzztbrY4rdCbOw1W7DmSq4mWJswJZxIw-xOqGbjIRExj-gsuVEO2zM00
chart.series[0].data.forEach(point => {
if (point.colorValue < 0) {
point.update({
color: 'red'
});
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.