|
From: jules h. <hu...@ha...> - 2011-02-14 12:24:11
|
Feel free to 'save and run', pass along, or ignore.
This was my valentine's day present today.
I hope the bandwidth amuses more than it annoys...
Jules
#----------------------------------
# hohumheart.py
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
# force square figure and square axes looks better for polar, IMO
width, height = mpl.rcParams['figure.figsize']
size = min(width, height)
# make a square figure
fig = plt.figure(figsize=(size, size))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#ffffff')
ax.set_rmax(2.0)
ax.set_xticks([])
ax.set_yticks([])
plt.grid(False)
theta = np.linspace(0,1,100)*np.pi*2
r = 1*(1-np.cos(theta))
ncards = 5
step = 2*np.pi/ncards
for ii in range(ncards):
tr = np.column_stack((theta+ii*step, r))
cpatch = Polygon(tr)
cpatch.set_facecolor('r')
cpatch.set_edgecolor('k')
cpatch.set_alpha(0.5)
ax.add_patch(cpatch)
ax.set_title("I $\heartsuit$ you", fontsize=20)
plt.show()
#-----------------------
|