title: Problem with plotting a list as a 3d scatter
body: <p>I'm working with the following code, which simulates a random walk in 2 dimensions. The walkers positions are stored on a list of tuples:</p>
  <pre><code># Comparação entre random walk e difusão em 1d
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  import random
  
  M = 100 # Número de walkers
  L = 100 # Tamanho da malha
  
  # A cada intervalo de tempo, mover o walker e propagar a difusão
  
  p = 0.1 # Probabilidade de andar
  pinv = 1.0-p
  nsteps = 2001 # Número de intervalos de tempo
  
  # Iniciando os walkers
  
  x = np.zeros(M) # Posição inicial dos walkers no eixo x
  Z = [(0,0) for i in range (M)]
  edgesrw = np.array(range(-L,L+1))-0.5
  xc = 0.5*(edgesrw[:-1]+edgesrw[1:])
  
  #%%
  
  def animate(it):
      global x
      x = get_data(Z, M)
  
      # Trajetória dos walkers nos eixos x e y
      if (np.mod(it,noutput)==0):
          plot.set_offsets(Z)
          ax.set_title('Tempo = {}'.format(it))
      return plot
  
  def get_data(Z, M):
      # Atualizar a posição de todos os walkers
      for iw in range(M):
          rndx = random.random()
          dx = -1*(rndx&lt;p)+1*(rndx&gt;pinv)
          rndy = random.random()
          dy = -1*(rndy&lt;p)+1*(rndy&gt;pinv)
          x, y = Z[iw]
          Z[iw] = x+dx, y+dy
      return Z
  
  plt.ion()
  noutput = 5
  fig, ax = plt.subplots()
  fig.set_size_inches(6, 6)
  ax.set_xlim((-100, 100))
  ax.set_ylim((-100, 100))
  ax.set_xlabel('Distância percorrida (x)')
  ax.set_ylabel('Distância percorrida (y)')
  x = get_data(Z, M)
  plot = ax.scatter (*zip(*Z), s = 1)
              
  ani = animation.FuncAnimation(fig = fig, func = animate, frames = nsteps, interval = 50)
  ani.save('randomwalk2d.gif')
  plt.show()
  </code></pre>
  <p>After running it, I have this as a result:</p>
  <p><a href="https://i.stack.imgur.com/MukMk.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MukMk.gif" alt="enter image description here" /></a></p>
  <p>What I'm trying to do now is expand this approach to 3 dimensions. I've added one more coordinate to each tuple and also added the random motion to the z axis, plus some other minor changes:</p>
  <pre><code># Comparação entre random walk e difusão em 1d
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  import random
  
  M = 100 # Número de walkers
  L = 100 # Tamanho da malha
  
  # A cada intervalo de tempo, mover o walker e propagar a difusão
  
  p = 0.1 # Probabilidade de andar
  pinv = 1.0-p
  nsteps = 2001 # Número de intervalos de tempo
  
  # Iniciando os walkers
  
  x = np.zeros(M) # Posição inicial dos walkers nos eixos x, y e z
  Z = [(0,0,0) for i in range (M)]
  edgesrw = np.array(range(-L,L+1))-0.5
  xc = 0.5*(edgesrw[:-1]+edgesrw[1:])
  
  #%%
  
  def animate(it):
      global x
      x = get_data(Z, M)
  
      # Trajetória dos walkers nos eixos x, y e z
      if (np.mod(it,noutput)==0):
          plot.set_offsets(Z)
          ax.set_title('Tempo = {}'.format(it))
      return plot
  
  def get_data(Z, M):
      # Atualizar a posição de todos os walkers
      for iw in range(M):
          rndx = random.random()
          dx = -1*(rndx&lt;p)+1*(rndx&gt;pinv)
          rndy = random.random()
          dy = -1*(rndy&lt;p)+1*(rndy&gt;pinv)
          rndz = random.random()
          dz = -1*(rndz&lt;p)+1*(rndz&gt;pinv)
          x, y, z = Z[iw]
          Z[iw] = x+dx, y+dy, z+dz
      return Z
  
  plt.ion()
  noutput = 5
  fig = plt.figure()
  ax = fig.add_subplot(111, projection = '3d')
  fig.set_size_inches(6, 6)
  ax.set_xlim((-100, 100))
  ax.set_ylim((-100, 100))
  ax.set_zlim((-100, 100))
  ax.set_xlabel('Distância percorrida (x)')
  ax.set_ylabel('Distância percorrida (y)')
  ax.set_zlabel('Distância percorrida (z)')
  x = get_data(Z, M)
  plot = ax.scatter (*zip(*Z), s = 1, color = 'Blue')
              
  ani = animation.FuncAnimation(fig = fig, func = animate, frames = nsteps, interval = 50)
  ani.save('randomwalk3d.gif')
  plt.show()
  </code></pre>
  <p>But when I run it, not a single walker leaves the origin:</p>
  <p><a href="https://i.imgur.com/GkkwV8A.mp4" rel="nofollow noreferrer">3d random walk attempt (failed)</a></p>
  <p>I know that the random walks are being calculated though, as I can check this through the console at the end of the simulation and the tuples are all over the place. I have tried multiple things I've seen on other questions here but nothing has worked so far and I don't know what I'm doing wrong.</p>