當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。