title: Line colour of 3D parametric curve in python's matplotlib.pyplot
body: <p>I've been googling quite some time with no success ... maybe my keywords are just lousy. Anyway, suppose I have three 1D <code>numpy.ndarray</code>s of the same length I'd like to plot them in 3D as a trajectory. Moreover, I'd like to be able to do either of the following things:</p>
  
  <ol>
  <li>Change the colour of the line as a function of <code>z</code></li>
  <li>Change the colour of the line as a function of time (i.e. the index in the arrays)</li>
  </ol>
  
  <p><a href="http://matplotlib.org/examples/mplot3d/lines3d_demo.html" rel="noreferrer">This demo</a> has an example of making such a curve:</p>
  
  <pre><code>import matplotlib as mpl
  from mpl_toolkits.mplot3d import Axes3D
  import numpy as np
  import matplotlib.pyplot as plt
  
  fig = plt.figure()
  ax = fig.gca(projection='3d')
  theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
  z = np.linspace(-2, 2, 100)
  r = z**2 + 1
  x = r * np.sin(theta)
  y = r * np.cos(theta)
  ax.plot(x, y, z)
  
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gH7ly.png" alt="enter image description here"></p>
  
  <p>But how do I achieve <code>1</code> or <code>2</code>? Solutions to only one or the other are welcome!
  Thanks in advance.</p>