当您的数据已经缩放时,即它已经代表 ggplot2 可以直接处理的美学值时,请使用这组比例。这些比例不会产生图例,除非您还提供 breaks 、 labels 以及所需的 guide 类型。
用法
scale_colour_identity(..., guide = "none", aesthetics = "colour")
scale_fill_identity(..., guide = "none", aesthetics = "fill")
scale_shape_identity(..., guide = "none")
scale_linetype_identity(..., guide = "none")
scale_linewidth_identity(..., guide = "none")
scale_alpha_identity(..., guide = "none")
scale_size_identity(..., guide = "none")
scale_discrete_identity(aesthetics, ..., guide = "none")
scale_continuous_identity(aesthetics, ..., guide = "none")
参数
- ...
 - 
其他参数传递给
discrete_scale()或continuous_scale() - guide
 - 
该量表的使用指南。默认为
"none"。 - aesthetics
 - 
字符串或字符串向量,列出了该比例所使用的美学名称。例如,这可以用于通过
aesthetics = c("colour", "fill")同时将颜色设置应用于colour和fill美学。 
细节
函数 scale_colour_identity() 、 scale_fill_identity() 、 scale_size_identity() 等适用于比例名称中指定的美观: colour 、 fill 、 size 等。但是,函数 scale_colour_identity() 和 scale_fill_identity() 还有一个可选的 aesthetics 参数,可用于通过单个函数调用定义 colour 和 fill 美学映射。函数 scale_discrete_identity() 和 scale_continuous_identity() 是通用尺度,可以与通过 aesthetics 参数提供的任何美学或一组美学一起使用。
例子
ggplot(luv_colours, aes(u, v)) +
  geom_point(aes(colour = col), size = 3) +
  scale_color_identity() +
  coord_fixed()
df <- data.frame(
  x = 1:4,
  y = 1:4,
  colour = c("red", "green", "blue", "yellow")
)
ggplot(df, aes(x, y)) + geom_tile(aes(fill = colour))
ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = colour)) +
  scale_fill_identity()
# To get a legend guide, specify guide = "legend"
ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = colour)) +
  scale_fill_identity(guide = "legend")
# But you'll typically also need to supply breaks and labels:
ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = colour)) +
  scale_fill_identity("trt", labels = letters[1:4], breaks = df$colour,
  guide = "legend")
# cyl scaled to appropriate size
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(size = cyl))
# cyl used as point size
ggplot(mtcars, aes(mpg, wt)) +
  geom_point(aes(size = cyl)) +
  scale_size_identity()
相关用法
- R ggplot2 scale_gradient 渐变色阶
 - R ggplot2 scale_shape 形状比例,又称字形
 - R ggplot2 scale_viridis 来自 viridisLite 的 Viridis 色标
 - R ggplot2 scale_grey 连续灰度色阶
 - R ggplot2 scale_linetype 线条图案的比例
 - R ggplot2 scale_discrete 离散数据的位置尺度
 - R ggplot2 scale_manual 创建您自己的离散尺度
 - R ggplot2 scale_colour_discrete 离散色阶
 - R ggplot2 scale_steps 分级渐变色标
 - R ggplot2 scale_size 面积或半径比例
 - R ggplot2 scale_date 日期/时间数据的位置刻度
 - R ggplot2 scale_continuous 连续数据的位置比例(x 和 y)
 - R ggplot2 scale_binned 用于对连续数据进行装箱的位置比例(x 和 y)
 - R ggplot2 scale_alpha Alpha 透明度比例
 - R ggplot2 scale_colour_continuous 连续色标和分级色标
 - R ggplot2 scale_linewidth 线宽比例
 - R ggplot2 scale_hue 离散数据的均匀间隔颜色
 - R ggplot2 scale_brewer ColorBrewer 的连续、发散和定性色标
 - R ggplot2 stat_ellipse 计算法行数据椭圆
 - R ggplot2 stat_identity 保留数据原样
 - R ggplot2 stat_summary_2d 以二维形式进行分类和汇总(矩形和六边形)
 - R ggplot2 should_stop 在示例中用于说明何时应该发生错误。
 - R ggplot2 stat_summary 总结唯一/分箱 x 处的 y 值
 - R ggplot2 stat_sf_coordinates 从“sf”对象中提取坐标
 - R ggplot2 stat_unique 删除重复项
 
注:本文由纯净天空筛选整理自Hadley Wickham等大神的英文原创作品 Use values without scaling。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
