Beautiful (and Nerdy) Polar Graphs


This is a short notebook on plotting some beautiful polar graphs in python using very simple functions and code. This something that can be taken as an exercise as well as a piece of art to admire and to learn.

Cardioid

This is one of the first curves I discovered when I was reading a book on differential calculus. It was an old book and was full of curve tracing. Cardioid as you might have guessed has it's roots in the greek word for heart. The equation is

$$r = a + b*cos(\theta)$$

where

$$\theta \in [\ 0, 2 \pi]\ $$

Of course it is plotted as a Polar Graph. If you wanna read up more on Cardioid and I suggest you should head over to the wikipedia page

Getting Started you'll need to start the Ipython Shell and import these


In [12]:
%matplotlib inline
import matplotlib.pyplot as plt
from numpy import *

Now that you have the basic setup let's start with plotting the cardioid. starting with setting up values of

$$\theta$$


In [13]:
theta = arange(0.0, 2*pi , 0.1)

now for the

$$a \& b$$


In [14]:
a = 1.0 
b = 1.0

$$r = $$


In [15]:
r = map(lambda x:a + b*cos(x),theta)

Now we plot it as a polar plot


In [16]:
plt.polar(theta, r)


Out[16]:
[<matplotlib.lines.Line2D at 0x7fc3ce0bb050>]

In [ ]: