0

我试图在 googlevis 图表中使用 alpha < 1 的一些颜色,但没有成功。

我应用的初始颜色列表是:

MyColors <- c('#DD4477', '#109618', '#AAAA11)

然后我应用函数adjustcolor:MyAlphaColors <- adjustcolor(MyColors, 0.4)

如果我尝试在 googlevis 图表中使用这些颜色,则会收到错误消息:#109618E6 is not a valid color string

我怎样才能克服这个问题并在我的 googlevis 图表中使用一些 alpha < 1 的颜色?

这是一个可重现的示例(在这种特殊情况下,我没有收到错误消息,但第二个系列的颜色未正确绘制):

library(googleVis)
MyColors <- c('#DD4477', '#109618', '#AAAA11')

df <- data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val1.style = MyColors, val2=c(23,12,32), val2.style = adjustcolor(MyColors, 0.4))

plot(gvisColumnChart(df, xvar="country", yvar=c(colnames(df)[2], colnames(df)[3], colnames(df)[4], colnames(df)[5]),
                     options=list(legend="none",
                                  chartArea = "{left:'10%',top:'10%',width:'80%',height:'70%'}",
                                  height=750,
                                  width=1050,
                                  backgroundColor = "white")
                     )
    )
4

0 回答 0