基于点颜色的R highcharter图例

时间:2017-11-29 20:03:55

标签: r highcharts r-highcharter

我有下面的代码和图表

xlat

enter image description here

对于图例,目前它是“系列1”,我想让它成为每个点颜色的点图例,即绿色,橙色和红色。并且还可以自定义图例文本。

传奇应该像:

(红点)20%分位数(绿点)40%分位数(橙色点)80%分位数

1 个答案:

答案 0 :(得分:3)

使用人工(空)系列创建图例条目:

highchart() %>%

   # add the series and exclude it from the legend
   hc_add_series(data = tmp, type = "line", showInLegend = F) %>% 

   # add three empty series for the legend entries. Change color and marker symbol
   hc_add_series(data = data.frame(), name = "20% Quantile", color = "#FF0000", marker = list(symbol = "circle"), type = "scatter") %>% 
   hc_add_series(data = data.frame(), name = "40% Quantile", color = "#00FF00", marker = list(symbol = "circle"), type = "scatter") %>% 
   hc_add_series(data = data.frame(), name = "80% Quantile", color = "#ffa500", marker = list(symbol = "circle"), type = "scatter")

enter image description here