ggformaEnglish

选择分类、连续或发散色板

函数索引 / 视觉设计与诊断

forma_palette() · scale_colour_forma() · scale_fill_forma()

给类别、数值强度或正负偏差选择对应的色阶,也可选择适合灰度输出的模式。

怎么用

forma_palette() 返回颜色;scale_colour_forma() 与 scale_fill_forma() 用于图层标度。主题和标度选相同的 mode。跨图保持分类配色时,应按原标识固定 limits。

返回结果

返回颜色字符向量,或可直接添加到图形的 ggplot2 标度。

调用方式

forma_palette(
  n,
  type = c("discrete", "sequential", "diverging"),
  reverse = FALSE,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

scale_colour_forma(
  type = c("discrete", "sequential", "diverging"),
  ...,
  reverse = FALSE,
  midpoint = 0,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

scale_fill_forma(
  type = c("discrete", "sequential", "diverging"),
  ...,
  reverse = FALSE,
  midpoint = 0,
  mode = c("light", "dark"),
  medium = c("colour", "greyscale")
)

参数

n、type、reverse、mode、medium、...、midpoint

逐项参数说明(英文)

R 示例

forma_palette(4)
ggplot2::ggplot(iris, ggplot2::aes(Sepal.Length, Petal.Length, colour = Species)) +
  ggplot2::geom_point() + scale_colour_forma()
ggplot2::ggplot(iris, ggplot2::aes(Species, fill = Species)) +
  ggplot2::geom_bar() + scale_fill_forma()

查看完整英文文档