HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
susam
heart
Python2019–2020
susam / heart

heart

Hearts drawn with Python Matplotlib and C

4Distinct people
5Mentions
0Explicit recommenders
42GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Hearts drawn with Python Matplotlib and C

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month5 dated mentions

Observed mentions: 2019-02-14 11:28:00 UTC to 2020-02-13 15:59:55 UTC.

01232019-02-01 00:00:00 UTC to 2019-03-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 commentsFeb 20192019-03-01 00:00:00 UTC to 2019-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-04-01 00:00:00 UTC to 2019-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-05-01 00:00:00 UTC to 2019-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-06-01 00:00:00 UTC to 2019-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-07-01 00:00:00 UTC to 2019-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-08-01 00:00:00 UTC to 2019-09-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 commentsAug 20192019-09-01 00:00:00 UTC to 2019-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-10-01 00:00:00 UTC to 2019-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-11-01 00:00:00 UTC to 2019-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-12-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2020-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-02-01 00:00:00 UTC to 2020-03-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsFeb 2020

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Feb 20192019-02-01 00:00:00 UTC2019-03-01 00:00:00 UTC312
Mar 20192019-03-01 00:00:00 UTC2019-04-01 00:00:00 UTC000
Apr 20192019-04-01 00:00:00 UTC2019-05-01 00:00:00 UTC000
May 20192019-05-01 00:00:00 UTC2019-06-01 00:00:00 UTC000
Jun 20192019-06-01 00:00:00 UTC2019-07-01 00:00:00 UTC000
Jul 20192019-07-01 00:00:00 UTC2019-08-01 00:00:00 UTC000
Aug 20192019-08-01 00:00:00 UTC2019-09-01 00:00:00 UTC110
Sep 20192019-09-01 00:00:00 UTC2019-10-01 00:00:00 UTC000
Oct 20192019-10-01 00:00:00 UTC2019-11-01 00:00:00 UTC000
Nov 20192019-11-01 00:00:00 UTC2019-12-01 00:00:00 UTC000
Dec 20192019-12-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
Jan 20202020-01-01 00:00:00 UTC2020-02-01 00:00:00 UTC000
Feb 20202020-02-01 00:00:00 UTC2020-03-01 00:00:00 UTC101

What Hacker News says

5 sources
I arrived at these equations in 2014 when I plotted a heart using Matplotlib for my girlfriend (now my wife). The code and output is available here: https://github.com/susam/heart/. Some of the Matplotlib defaults have changed since then. With the current version of Matplotlib, the following code would produce good results: https://gist.github.com/susam/2a7e38ba632c4a2780fad421d1ca5f.... Today, I thought of sharing a WolframAlpha link to this plot here on Hacker News. I am glad you all liked it! :-) By the way, I've explained these equations step-by-step along with graph plots for every step in this 6 year old Reddit thread: https://www.reddit.com/comments/1xwuv3/math/cffeykn/.
In Wolfram Alpha: {y = Re(sqrt(abs(x)(1-abs(x)))), y = Re(-sqrt(1-sqrt(abs(x))))}
In the README of the repository, I have mentioned a link to a five year old Reddit thread where I have discussed this in detail. Here's the reddit thread: https://www.reddit.com/r/math/comments/1xwuv3/a_mathematical... Some of the "plot" links to WolframAlpha in that thread do not show the example graphs anymore, so let me rewrite that comment here with updated links. Rewritten comment with updated link now follows. --- I wanted something that resembles the hearts in playing cards more than it resembles a cardoid, so I made a simpler heart for my girlfriend (now my wife) composed of two simple curves. The heart is plotted with two semicircles and segments of two quartic curves. Here is an explanation of how I arrived at these equations. PART 1 - Plotting the Two Semicircles First, we want to draw a circle of radius 1/2 centered at (1/2, 0
Read the rest
). We start with an equation of a circle: (x - 1/2)^2 + y^2 = (1/2)^2 ⇔ x^2 - x + y^2 = 0 ⇔ y^2 = x(1 - x). Plot: https://www.wolframalpha.com/input/?i=y%5E2%20%3D%20x%281%20... With the previous equation, we got both negative and positive values of y, hence a full circle. We want to eliminate the negative values of y, thereby resulting in a semicircle lying above the x-axis. We take square root of both sides: y = sqrt(x(1 - x)). Plot: https://www.wolframalpha.com/input/?i=sqrt%28x%281%20-%20x%2... Now, we want a mirror image of this curve on the left side of the y-axis, i.e., for negative values of x, we want the same values of y that we see in the above plot. We do this by substituting x with |x| in the above equation: y = sqrt(|x|(1 - |x|)). Plot: https://www.wolframalpha.com/input/?i=Re%28sqrt%28abs%28x%29... This completes the top portion of the heart with two semicircles. PART 2 - Plotting the Segments of Two Quartic Curves Now we try to complete the bottom portion of the heart. I didn't start with quartic curves. Instead, I began with parabolas and arrived at quartic curves. We begin with a single parabola: y^2 = 1 - x. Plot: https://www.wolframalpha.com/input/?i=y%5E2+%3D+1+-+x We go through the same drill. We first eliminate negative values of y and then mirror the graph on the left side of the y axis: y = sqrt(1 - |x|). Plot: https://www.wolframalpha.com/input/?i=Re%28sqrt%281%20-%20ab... Let us get a mirror of this plot below the x-axis by multiplying the right hand side by -1: y = -sqrt(1 - |x|). Plot: https://www.wolframalpha.com/input/?i=Re%28-sqrt%281%20-%20a... But I wanted to get a little bit of concave curvature at the bottom of the curves to resemble the hearts in playing cards. I could get this by a little trick I learnt somewhere online: We can vary the power of |x| between 0.5 and 1.0 to get different curvatures, i.e., we can vary r in y = -sqrt(1 - |x|^r) where 0.5 <= r <= 1.0 to get different curvatures. I liked the concave curvature with r = 0.5, so I chose y = -sqrt(1 - sqrt(|x|)). This turns the segments of parabolas into segments of quartic curves. Plot: https://www.wolframalpha.com/input/?i=Re%28-sqrt%281%20-%20s... PART 3 - Plotting the Two Curves Together Let us combine the two equations together. The equations for both curves are: y = sqrt(|x|(1 - |x|)), y = -sqrt(1 - sqrt(|x|)). Plot: https://www.wolframalpha.com/input/?i=%7By%20%3D%20Re%28sqrt... PART 4 - Scaling the Second Curve Finally, in the actual plot I printed, laminated, and presented to my girlfriend, I have multiplied the second equation by 1.5 to stretch the bottommost point of the heart from y = -1 to y = -1.5. Since I used equal scaling (aspect ratio = 1) for both axes and printed it without any scaling to get a high quality print, stretching the bottom of the heart was necessary to make the heart look beautiful and wholesome. Plot: https://github.com/susam/heart/blob/master/heart-2014-02-14....
In Plotting hearts with Python and C

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.