R中的ggplot2中的rgb()(rgb() with ggplot2 in R)

编程入门 行业动态 更新时间:2024-10-25 18:33:36
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"

更多推荐

本文发布于:2023-07-27 17:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1293611.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:rgb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!