学习心型函数,参考ReferenceBlog

library(tidyverse)
heart_vertices <- function(xc,yc,size,npoints=100,...){
    #area = pi*r*r for circle... this heart has area of 180 = r*r
    radius = size*0.05  ## I'm not set on this...  I just wanted to make size smaller 
    yc = yc + 0.1*radius  ## Just adjusting center of heart bit
    t = seq(-pi,pi, length.out=npoints+1)
    x = xc + 16 * radius *(sin(t))^3
    y = yc + radius*13*cos(t) - radius*5*cos(2*t) - radius*2*cos(3*t) - radius*cos(4*t)
    df <- tibble(theta=t,x=x,y=y) 
    return(df)
}

p <- 
    heart_vertices(0,0,1) %>%
    ggplot() +
    geom_line(aes(x=theta, y=x), color="#D22042de") +  
    geom_line(aes(x=theta, y= -x),color="#D22042de",linetype=3) +  ## this is just to make a design
    geom_line(aes(x=theta, y=y), color="#30C4C9de") +
    geom_line(aes(x=theta, y= -y), color="#30C4C9de", linetype=3) + ## this is just to make a design
    geom_polygon(aes(x=x,y=y), fill="#615375de", ## to draw heart use x=x,y=y
           color="#61537520",size=10) + ## I'm just playing around with line around filled part. 
    scale_x_continuous(breaks=c(-pi,-pi/2,0,pi/2,pi), labels=c("-pi","","0","","pi")) +
    annotate("text", x = 1.4, y = -0.75, size = 3, label = "For you. Legend Moon.") +
    coord_fixed() +
    # labs(x="",y="", caption="For you. Legend Moon.") +
    ggplot2::theme_void()

x = 1.4 主要是为了满足微信朋友圈的封面的位置要求。

p

# ggsave("heart_shape.png")