plotly和R中的rgb透明颜色

标签 r rgb plotly

我试图获得一个带有半透明紫色填充区域的 plotly 图。我可以很好地找到 rgb 名称并让它在一个简单的图中工作。但似乎 plotly 并没有以 rgb 的通常方式读取?

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

plot with purple squares
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)

plot with green fill

最佳答案

根据 plotly 网站,可以在此处找到 rgb/hex 的完整列表( http://reeddesign.co.uk/test/namedcolors.html )。因此,对于您的示例,您需要使用 fillcolor="#8a2be2" .或者,您也可以使用类似这样的东西 fillcolor="rgba(147,112,219,0.1)最后一位数字是 alpha(不透明度)

关于plotly和R中的rgb透明颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35213766/

相关文章:

R:将行 reshape 为列并用 NA 填充

arrays - 在 R 中保存 3d 数组的最佳方法

r - 对子集使用表可获取整个 DF 而不是子集的频率

image - 在 Matlab 中将 RGB 图像转换为索引图像而不减少颜色

r - 在 ggplotly 中设置工具提示参数时,geom_line 不绘制

python - plotly dash 不刷新

r - 编织错误。未找到对象

python - tkinter 在 python 中渲染错误的 RGB 阴影

c++ - 将 YCCK jpeg 转换为 RGB

javascript - plotly.js - 如何修复条形图中条形之间的空间