Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
draw a spiral in matplotlib
import numpy as np
import matplotlib.pyplot as plt
#As a path collection
from matplotlib.collections import LineCollection
fig, ax = plt.subplots()
r = np.arange(0, .075, 0.00001)
nverts = len(r)
theta = np.array(range(nverts)) * (2*np.pi)/(nverts-1)
theta = 90*np.pi*r
xoffset, yoffset = .5, .5
yy = 1.4*r * np.sin(theta) + yoffset
xx = r * np.cos(theta) + xoffset
spiral = zip(xx,yy)
collection = LineCollection([spiral], colors='k')
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
# In polar coordinates
fig, ax = plt.subplots(subplot_kw=dict(polar=True, axisbg='none'), figsize=(.5,.5))
r = np.arange(0, 3.4, 0.01)
theta = 2*np.pi*r
ax.plot(theta, r, linewidth=2, color='k');

greninja commented Jan 2, 2017

Nothing happens. No plot appears.

@greninja: Try using at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment