Highcharter:调整多个系列的颜色
Highcharter: Adjust colours for multiple series
我正在尝试将多层添加到 highcharter plots。我不确定如何独立调整每一层的颜色。我希望每个组都具有相同的颜色和较低不透明度的背景多边形。下面是一个工作示例。也许有更好的方法来构建图层。
library(highcharter)
data(iris)
hull <- data.frame(x=c(5.5,4.5,4.3,4.6,5.2,5.7,5.8,5.7,6.2,5,4.9,5.4,6,7,6.8,7.7,6,4.9,6.2,7.7,7.9),y=c(3.5,2.3,3,3.6,4.1,4.4,4,3.8,2.2,2,2.4,3,3.4,3.2,2.8,2.6,2.2,2.5,3.4,3.8,3.8),Species=c('setosa','setosa','setosa','setosa','setosa','setosa','setosa','setosa','versicolor','versicolor','versicolor','versicolor','versicolor','versicolor','versicolor','virginica','virginica','virginica','virginica','virginica','virginica'))
hchart(hull,"polygon",hcaes(x,y,group="Species",opacity=0.2)) %>%
hc_add_series(data=iris,type="scatter",hcaes(Sepal.Length,Sepal.Width,group="Species"),showInLegend=F) %>%
hc_colors(colors=c("#A6CEE3","#1F78B4","#B2DF8A","#33A02C"))
这是您想要的方式吗
hchart(hull,"polygon",hcaes(x,y,group="Species",opacity=0.5)) %>%
hc_add_series(
data=iris,type="scatter",
hcaes(
Sepal.Length,
Sepal.Width,
group="Species",
color = c(setosa = "#A6CEE3",versicolor = "#1F78B4",virginica = "#B2DF8A")[Species]
),
showInLegend=F
) %>%
hc_colors(colors=c("#A6CEE399","#1F78B499","#B2DF8A99","#33A02C99"))
您可以通过在末尾添加两个字符来为十六进制颜色添加不透明度,在本例中我使用了 99
希望对您有所帮助
我正在尝试将多层添加到 highcharter plots。我不确定如何独立调整每一层的颜色。我希望每个组都具有相同的颜色和较低不透明度的背景多边形。下面是一个工作示例。也许有更好的方法来构建图层。
library(highcharter)
data(iris)
hull <- data.frame(x=c(5.5,4.5,4.3,4.6,5.2,5.7,5.8,5.7,6.2,5,4.9,5.4,6,7,6.8,7.7,6,4.9,6.2,7.7,7.9),y=c(3.5,2.3,3,3.6,4.1,4.4,4,3.8,2.2,2,2.4,3,3.4,3.2,2.8,2.6,2.2,2.5,3.4,3.8,3.8),Species=c('setosa','setosa','setosa','setosa','setosa','setosa','setosa','setosa','versicolor','versicolor','versicolor','versicolor','versicolor','versicolor','versicolor','virginica','virginica','virginica','virginica','virginica','virginica'))
hchart(hull,"polygon",hcaes(x,y,group="Species",opacity=0.2)) %>%
hc_add_series(data=iris,type="scatter",hcaes(Sepal.Length,Sepal.Width,group="Species"),showInLegend=F) %>%
hc_colors(colors=c("#A6CEE3","#1F78B4","#B2DF8A","#33A02C"))
这是您想要的方式吗
hchart(hull,"polygon",hcaes(x,y,group="Species",opacity=0.5)) %>%
hc_add_series(
data=iris,type="scatter",
hcaes(
Sepal.Length,
Sepal.Width,
group="Species",
color = c(setosa = "#A6CEE3",versicolor = "#1F78B4",virginica = "#B2DF8A")[Species]
),
showInLegend=F
) %>%
hc_colors(colors=c("#A6CEE399","#1F78B499","#B2DF8A99","#33A02C99"))
您可以通过在末尾添加两个字符来为十六进制颜色添加不透明度,在本例中我使用了 99
希望对您有所帮助