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


R語言 palette()用法及代碼示例


R語言中的palette()函數用於設置或查看Graphics Palette。

用法: palette(value)

參數:
value:一個可選的字符向量。

範例1:


# R program to illustrate
# palette function
  
# Calling the palette() function
# to obtain the current palette
palette()

輸出:

[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow" 
[8] "gray"  

範例2:


# R program to illustrate
# palette function
  
# Calling the palette() function
# to set 2 extra Graphics Palette
palette(c(palette(), "purple", "brown"))
  
# Viewing the final added Graphics Palette
palette()

輸出:

[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow" 
[8] "gray"    "purple"  "brown"  

相關用法


注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Set or View the Graphics Palette in R Programming – palette() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。