2017-11-29 12 views
0

は、私は現在、それは「シリーズ1」で、伝説についてRのhighcharter伝説ポイントカラーに基づいて

tmp <- data.frame(x = 1:5, y = rnorm(5), 
color = c("#00FF00", "#FF0000", "#00FF00", "#ffa500", "#FF0000")) 

highchart() %>% 
    hc_add_series(data= tmp, hcaes(x = x, y = y, color = color), type = "line") 

enter image description here

以下のコードとプロットを持って、私は、各ポイントのためにそれにポイントの伝説を作りたいです色は緑、オレンジ、赤です。凡例のテキストをカスタマイズすることもできます。

凡例のようになります

(赤点)の20%分位数(緑点)40%分位(オレンジ点)凡例エントリを作成するための人工的な(空の)系列を使用し、80%分位

+0

あなたが欲しい各ポイントが含まれているシリーズを作成する必要があるとすることができません。ハイチャートの伝説の色はシリーズのものであり、ポイントではありません。 – wergeld

答えて

2

ました:

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

関連する問題