Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6786171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:12:50+00:00 2026-05-26T17:12:50+00:00

Possible Duplicate: Equation-driven smoothly shaded concentric shapes How could I plot a symmetrical heart

  • 0

Possible Duplicate:
Equation-driven smoothly shaded concentric shapes

How could I plot a symmetrical heart in R like I plot a circle (using plotrix) or a rectangle?

I’d like code for this so that I could actually do it for my self and to be able to generalize this to similar future needs. I’ve seen even more elaborate plots than this so it’s pretty doable, it’s just that I lack the knowledge to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:12:51+00:00Added an answer on May 26, 2026 at 5:12 pm

    This is an example of plotting a “parametric equation”, i.e. a pairing of two separate equations for x and y that share a common parameter. You can find many common curves and shapes that can be written within such a framework.

    dat<- data.frame(t=seq(0, 2*pi, by=0.1) )
     xhrt <- function(t) 16*sin(t)^3
     yhrt <- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
     dat$y=yhrt(dat$t)
     dat$x=xhrt(dat$t)
     with(dat, plot(x,y, type="l"))
    

    Other Parametric (and implicit and polar) Heart Eqns

    You also could “heat it up” with using the “fill” capability of the polygon function:

    with(dat, polygon(x,y, col="hotpink"))   
    

    And if you just want little hearts to sprinkle around at various places, you could use the Symbol font version of “heart” after looking at the help(points) page and using the TestChars function:

    points(c(10,-10, -15, 15), c(-10, -10, 10, 10), pch=169, font=5)
    

    enter image description here

    Windows users may want to see if adding the Cairo package helps gain access to card symbols including “hearts”.( When I tested the TestChars function on the WinXP “side” of my MacPro I did not get hearts, and paging through the “special symbols” in MS-Word did not uncover anything. So I did a search of Rhelp and found a recent posting by Ivo Welch. He was reporting a bug, but they look OK on my machine.) Further note… I think the hearts and diamonds codes in his were reversed.

    library(Cairo)
    
    clubs <- expression(symbol('\247'))
    hearts <- expression(symbol('\251'))
    diamonds <- expression(symbol('\250'))
    spades <- expression(symbol('\252'))
    csymbols <- c(clubs, hearts, diamonds, spades)
    
    plot( 0, xlim=c(0,5), ylim=c(0,2), type="n" )
    clr <- c("black", "red", "red", "black") 
    for (i in 1:4) {
      hline <- function( yloc, ... ) 
             for (i in 1:length(yloc)) 
                 lines( c(-1,6), c(yloc[i],yloc[i]), col="gray")  
                  hline(0.9); 
                    hline(1.0);
                    hline(1.1);
                    hline(1.2)  
     text( i, 1, csymbols[i], col=clr[i], cex=5 )  
     text( i, 0.5, csymbols[i], col=clr[i] ) }
    
    # Also try this
    plot(1,1)
    text(x=1+0.2*cos(seq(0, 2*pi, by=.5)), 
         y=1+0.2*sin(seq(0, 2*pi, by=.5)), 
                      expression(symbol('\251') ) )
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
Possible Duplicate: Solving a linear equation I need to programmatically solve a system of
Possible Duplicate: Why do I see a double variable initialized to some value like
Possible Duplicate: ggplot2: Adding Regression Line Equation and R2 on graph I'm graphing data
Possible Duplicate: MD5 algorithm in Objective C I need to hash a string using
Possible Duplicate: Circle line collision detection I'm trying to do collision testing between a
Possible Duplicate: C# driver development? I would like to know if I can do
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.