打印和R中的RGB透明颜色 [英] rgb transparent colors in plotly and R
本文介绍了打印和R中的RGB透明颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获得一个带有半透明紫色填充区域的曲线图。我可以找到RGB的名称,并让它在一个简单的情节工作。但似乎PLATLY不是以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)
推荐答案
根据Ploly网站,这里有可用的rgb/十六进制的完整列表(http://reeddesign.co.uk/test/namedcolors.html)。因此,对于您的示例,您需要使用fillcolor="#8a2be2"
。或者,您也可以使用类似的fillcolor="rgba(147,112,219,0.1)
,最后一个数字是字母(不透明度)
这篇关于打印和R中的RGB透明颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文