英文:
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:
ggplot(data = h, aes(x = x, y = y)) +
geom_path(color = "maroon", fill = "red") +
theme_void()
This change will fill the path in red while keeping the maroon color for the lines.
英文:
I have this plot:
h <-
data_frame(t = seq(0, (2 * pi), by = 0.005),
x = 13 * sin(t)^3,
y = 13 * cos(t) -
5 * cos(2 * t) -
2 * cos(3 * t) -
1 * cos(4 * t),
chunk = floor(x)) %>%
select(-t)
ggplot(data = h, aes(x = x, y = y)) +
geom_path(color = "maroon")+
theme_void()
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
代替:
ggplot(data = h, aes(x = x, y = y)) +
geom_polygon(fill = "red") +
theme_void()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论