Skip to content
scipython.com

E3.5A cardioid

A cardioid is the plane figure described in polar coordinates by \(r = 2a(1+\cos\theta)\) for \(0 \le \theta \le 2\pi\):

import numpy as np
import matplotlib.pyplot as plt

theta = np.linspace(0, 2.*np.pi, 1000)
a = 1.
r = 2 * a * (1. + np.cos(theta))
plt.polar(theta, r)
plt.show()

The polar graph plotted by this code is illustrated below.

A cardioid