我有下面的代码和图表
xlat
对于图例,目前它是“系列1”,我想让它成为每个点颜色的点图例,即绿色,橙色和红色。并且还可以自定义图例文本。
传奇应该像:
(红点)20%分位数(绿点)40%分位数(橙色点)80%分位数
答案 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")