Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
Created February 3, 2015 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoguaro/71372e19b1c95fae3043 to your computer and use it in GitHub Desktop.
Save nicoguaro/71372e19b1c95fae3043 to your computer and use it in GitHub Desktop.
"""
Plot multiple butterfly curves.
"""
import numpy as np
import matplotlib.pyplot as plt
def curve(turns, npts):
t = np.linspace(0, 2*turns*np.pi, npts)
x = np.sin(t)*(np.exp(np.cos(t))- 2*np.cos(4*t) - np.sin(t/12)**5)
y = np.cos(t)*(np.exp(np.cos(t))- 2*np.cos(4*t) - np.sin(t/12)**5)
return x, y
inc = 0.2
ncur = 4
x, y = curve(10, 10000)
for k in range(ncur):
plt.plot((1+k*inc)*x, (1+k*inc)*y, zorder=ncur+3-k)
plt.axis('tight')
plt.axis('off')
plt.savefig('gift.svg')
plt.savefig('gift.png', dpi=600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment