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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。