简体   繁体   English

rgb透明色在plotly和R.

[英]rgb transparent colors in plotly and R

I am trying to get a plotly graph with a filled area that is semi-transparent purple. 我试图获得一个填充区域为半透明紫色的图形图形。 I can find the rgb designation fine and get it to work in a simple plot. 我可以找到rgb指定正常并让它在一个简单的情节中工作。 But it seems that plotly doesn't read in rgb's the usual way? 但似乎情节并没有以通常的方式阅读rgb?

plot(rnorm(10),col="#A020F066",pch=15,cex=13)
# plots squares that are transparent purple (expected)

情节与紫色方块

p=plot_ly(x=c(1,2,3,4),y=c(1,2,5,10),type="scatter",line=list(color="red"))
p=add_trace(p,x=c(1,2,3,4),y=c(11,12,15,20),type="scatter",
        fillcolor="#A020F066",fill="tonexty",
        line=list(width=10),marker=list(size=10))
p
# plots area that is transparent mint green (What? I expected purple)

情节与绿色填充

According to the plotly website, the full list of rgb / hex available is found here ( http://reeddesign.co.uk/test/namedcolors.html ). 根据情节网站,可在此处找到rgb / hex的完整列表( http://reeddesign.co.uk/test/namedcolors.html )。 So for your example, you would need to use fillcolor="#8a2be2" . 因此,对于您的示例,您需要使用fillcolor="#8a2be2" Alternatively, you can also use something like this fillcolor="rgba(147,112,219,0.1) with the last digit being the alpha (opacity) 或者,你也可以使用像fillcolor="rgba(147,112,219,0.1)这样的东西,最后一个数字是alpha(不透明度)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM