当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R语言 colors()用法及代码示例


R 语言中的 colors() 函数用于显示 R 编程中包含的所有 657 种颜色名称。

用法: colors()
参数: 
Does not accept any parameters. 
 

范例1:

Python3


# R program to illustrate
# colors function
 
# Calling the colors() function
# to show all the 657 colors that
# names are contained in
# R programming
colors()

输出:



[1] "white"                "aliceblue"            "antiquewhite"        
[4] "antiquewhite1"        "antiquewhite2"        "antiquewhite3"       
[7] "antiquewhite4"        "aquamarine"           "aquamarine1"
...
...
[655] "yellow3"              "yellow4"              "yellowgreen"

范例2:

Python3


# R program to illustrate
# colors function
 
# Calling the colors() function
# with specific serial number of
# color names contained in R
# Programming
colors()[1]
colors()[3]
colors()[10]
colors()[655]
colors()[656]

输出:

[1] "white"
[1] "antiquewhite"
[1] "aquamarine2"
[1] "yellow3"
[1] "yellow4"

相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Get a List of all the 657 colors in R Programming – colors() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。