title: Making a 3D scatterplot that changes colors depending on value of Z
body: <p>I want to make a simple loop that makes a 3D scatterplot.
  but, i want two colors, depending on value of z in my data.</p>
  <p>I know i am doing something wrong with my loop, but can anyone tell me what is wrong?</p>
  <p>My code looks like this</p>
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  import numpy as np
  
  data = np.loadtxt('Koordinater/Co_sektions.txt')
  z = data[:,2]
  fig = plt.figure(figsize=(10,7))
  ax = plt.axes(projection = &quot;3d&quot;)
  ax.set_zlim(0, 27000)
  
  d1 = range(0,len(data),1)
  
  for i in d1:
      if z[i] &lt;= 1000:
          ax.scatter3D(data[:,1], data[:,0], data[:,2],color='red')
      else:
          ax.scatter3D(data[:,1], data[:,0], data[:,2])
  plt.show()
  
  </code></pre>
  <p>My data looks like</p>
  <pre><code>     0  -14450       0
    1583  -14450     902
    1583   14450     902
       0   14450       0
    3166   14450    1704
    3166  -14450    1704
    4749  -14450    2414
    4749   14450    2414
    6332  -14450    3036
    6332   14450    3036
    7915   14450    3576
  </code></pre>