R中的ggplot2中的rgb()(rgb() with ggplot2 in R)
在ggplot2中,我们可以选择按名称或十六进制代码设置颜色。 有没有办法以相同的方式使用rgb值? 我搜索了文档,但快速回答似乎是'不'。 (我想使用rgb的原因是我有一些颜色可以用于某些情节,并且我可以使用rgb格式,我可以从这里找到十六进制,但是如果这样做会很棒我可以直接将值输入到ggplot() 。
In ggplot2, we have the option of setting colours by name or hex code. Is there any way to use rgb values in the same way? I searched the docs but the quick answer seems to be 'no'. (The reason I would like to use rgb is that I have some colours that I am going to use for some plots, and I have them all in rgb format. I can get the hex from places like here, but it would be great if I could just enter the values straight into ggplot().
最满意答案
您可以使用函数rgb将小数RGB值转换为十六进制。
rgb(0.1,0.2,0.3) [1] "#1A334D"You can use the function rgb to convert fractional RGB values to hex.
rgb(0.1,0.2,0.3) [1] "#1A334D"更多推荐
发布评论