【问题标题】:scale_fill_identity does not fill anythingscale_fill_identity 不填充任何东西
【发布时间】:2023-01-26 01:23:33
【问题描述】:

我已经在我的一些代码中使用了 scale_fill_identity 函数。现在 - 突然之间 - 使用它时 - 它不会填充任何东西。

这里有一个例子:

# Create example data
data <- data.frame(x = c(1, 2, 3), y = c(4, 5, 6), fill = c("red", "blue", "yellow"))

# Create the plot
ggplot(data) +
  geom_point(aes(x = x, y = y, fill = fill)) +
  scale_fill_identity()

这给了我这个:

所以没有颜色。问题可能出在哪里的任何建议?

【问题讨论】:

    标签: ggplot2 rstudio fill


    【解决方案1】:

    你可以颜色你的积分使用scale_color_identity

    library(ggplot2)
    # Create the plot
    ggplot(data) +
      geom_point(aes(x = x, y = y, color = fill)) +
      scale_color_identity()
    

    创建于 2023-01-25 reprex v2.0.2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-24
      • 2016-03-25
      相关资源
      最近更新 更多