Skip to content

Instantly share code, notes, and snippets.

@mango314
Last active October 30, 2015 08:58
Show Gist options
  • Save mango314/8fa9b2e65be5119cab4b to your computer and use it in GitHub Desktop.
Save mango314/8fa9b2e65be5119cab4b to your computer and use it in GitHub Desktop.
rm foo*.png
convert -delay 10x100 foo*.png foo.gif

[1] I tried using Python's matplotlib on the logarithm and here is what I got, a kind of starburst pattern. Since the angle jumps between $\theta = 0$ and $\theta = 2\pi$, contour assumes there is a contour line between those those two points. Here in in fact $\bbox[#EEEDAA,1pt]{0=2\pi}$

Perhaps instead of matplotlib.pyplot.contour the contour lines can be connected with meshgrid and numpy.where statements.

Contour Plot of $\log z$ on $z \in [-1,1] + i[-1,1]$

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize']=4,4

plt.contour(
    np.arange(-1,1,0.01),
    np.arange(-1,1,0.01), 
    np.angle(t[...,None] + 1j*t[None,...]) , 
    levels = 2*np.pi*np.arange(-1,1,0.025)
)

enter image description here

# plt.contour assumes there are lines between theta = 0 and theta = 2*np.pi
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline
plt.rcParams['figure.figsize']=7,7
# rm foo*.png
# convert foo*.png foo.gif
dt = 0.01
L = 5
t = np.arange(-L,L+dt, dt)
z = t[...,None]+1j*t[None,...]
N = 20
PP = np.polyval(P,z)
for k in np.arange(N):
print "%02d" %(k)
w = np.log(np.exp(2j*np.pi*(k*1.0/N))*PP)
ds = 0.05
plt.contour(t, t, w.imag%(2*np.pi), levels = 2*np.pi*np.arange(0,1, ds), colors=('#505050','#707070'), linewidth=1)
plt.contour(t, t, w.imag%(2*np.pi), levels = 2*np.pi*np.arange(0,1, 0.5), colors='w', linewidth=50)
plt.contour(t, t, w.real, levels = np.arange(0,5,0.1)**1, colors=('#A2D426','#6B6CED'))
L = 3
plt.xlim([-L,L])
plt.ylim([-L,L])
#plt.show()
plt.savefig('/home/jdm/Documents/math/foo-%02d.png'%(k))
plt.clf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment