使用geom_path在红色中填充一个心形。

huangapple go评论102阅读模式
英文:

fill a heart in red with geom_path

问题

You can fill the plot in red by adding the fill aesthetic to geom_path in your ggplot code. Here's the modified code:

  1. ggplot(data = h, aes(x = x, y = y)) +
  2. geom_path(color = "maroon", fill = "red") +
  3. theme_void()

This change will fill the path in red while keeping the maroon color for the lines.

英文:

I have this plot:

  1. h <-
  2. data_frame(t = seq(0, (2 * pi), by = 0.005),
  3. x = 13 * sin(t)^3,
  4. y = 13 * cos(t) -
  5. 5 * cos(2 * t) -
  6. 2 * cos(3 * t) -
  7. 1 * cos(4 * t),
  8. chunk = floor(x)) %>%
  9. select(-t)
  10. ggplot(data = h, aes(x = x, y = y)) +
  11. geom_path(color = "maroon")+
  12. theme_void()

使用geom_path在红色中填充一个心形。

How can I fill it in red ?
I do not know how to do it with geom_path.

答案1

得分: 1

geom_path没有fill美学属性,因为它用于创建路径,而不是闭合的形状。请改用geom_polygon代替:

  1. ggplot(data = h, aes(x = x, y = y)) +
  2. geom_polygon(fill = "red") +
  3. theme_void()
英文:

geom_path does not have a fill aesthetic, because it is used to create a path, not closed shapes. Use geom_polygon instead:

  1. ggplot(data = h, aes(x = x, y = y)) +
  2. geom_polygon(fill = "red") +
  3. theme_void()

使用geom_path在红色中填充一个心形。

huangapple
  • 本文由 发表于 2023年5月22日 15:57:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304083.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定