title: Plotly displayed nothing when using for loop in a notebook
body: <p>The idea is  to plot and get the following figure.</p>
  
  <p><a href="https://i.stack.imgur.com/hmzrT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hmzrT.png" alt="enter image description here"></a></p>
  
  <p>The following code were used to get the above </p>
  
  <pre><code>from random import randint
  import plotly.graph_objects as go
  
  
  x1 = [randint(0, 9) for p in range(0, 10)]
  x2 = [randint(0, 9) for p in range(0, 10)]
  x3 = [randint(0, 9) for p in range(0, 10)]
  
  time=list(range(0, len(x1))) 
  
  fig = go.Figure()
  
  
  fig.add_trace(go.Scatter(x=time, y=x1,
                      mode='lines',
                      name='X1'))
  
  fig.add_trace(go.Scatter(x=time, y=x2,
                      mode='lines',
                      name='X2'))
  
  
  fig.add_trace(go.Scatter(x=time, y=x3,
                      mode='lines',
                      name='X3'))
  </code></pre>
  
  <p>But, to make the code more efficient, I tried something like this which I got from this <a href="https://community.plot.ly/t/when-using-plotly-inside-a-loop-nothing-is-printed/5839" rel="nofollow noreferrer">link</a></p>
  
  <p>Data=[x1,x2,x3]  ## This maybe wrong</p>
  
  <pre><code>   for i in range(0,2):
        trace = go.Scatter( x = times,
                                 y = data[:, i],
                                 mode = 'markers+lines'
                               )
  </code></pre>
  
  <p>Nothing come up whenever I tried to use for loop to plot a graph using plotly.</p>
  
  <p>Appreciate for any help.
  Thanks</p>