how to draw a heart with pylab


Question

How to draw a heart with pylab? I searched with google for ways to draw the picture but i want know how to draw it with pylab. Can someone help? The picture should look like this:

3D Heart

1
9
12/18/2010 4:41:57 PM

Using the linked formula in the other solution:

import pylab
x = scipy.linspace(-2,2,1000)
y1 = scipy.sqrt(1-(abs(x)-1)**2)
y2 = -3*scipy.sqrt(1-(abs(x)/2)**0.5)
pylab.fill_between(x, y1, color='red')
pylab.fill_between(x, y2, color='red')
pylab.xlim([-2.5, 2.5])
pylab.text(0, -0.4, 'Stack Overflow', fontsize=24, fontweight='bold',
           color='white', horizontalalignment='center')
pylab.savefig('heart.png')

heart

8
12/18/2010 3:21:13 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon