title: Plotly (offline) for Python click events
body: <p>I need to get click events in Plotly (offline) in Jupyter. </p>
  
  <p>The way I am thinking to handle this is use javascript and the following command to return the values to python:</p>
  
  <pre><code>var kernel = IPython.notebook.kernel;
  kernel.execute(command);
  </code></pre>
  
  <p>...where command would be something like <code>variable = xxxxx</code> (just like <a href="https://stackoverflow.com/questions/43759543/how-to-get-active-kernel-name-in-jupyter-notebook">here</a>)</p>
  
  <p>I am stucked in the beggining of my attempt, trying to plot a chart in HTML in python (observe that I can succesfully load jQuery this way):</p>
  
  <pre><code>from IPython.display import HTML
  HTML('''
      &lt;html&gt;
          &lt;head&gt;
              &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
              &lt;script src="https://cdn.plot.ly/plotly-latest.min.js"&gt;&lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;h3&gt;Gráfico&lt;/h3&gt;
              &lt;hr&gt;
              &lt;div id="myDiv"&gt;&lt;/div&gt;
              &lt;script&gt;
  
                  var trace1 = {
                    x: [1, 2, 3, 4],
                    y: [10, 15, 13, 17],
                    mode: 'markers'
                  };
  
                  var trace2 = {
                    x: [2, 3, 4, 5],
                    y: [16, 5, 11, 10],
                    mode: 'lines'
                  };
  
                  var trace3 = {
                    x: [1, 2, 3, 4],
                    y: [12, 9, 15, 12],
                    mode: 'lines+markers'
                  };
  
                  var data = [ trace1, trace2, trace3 ];
                  var layout = {};
                  Plotly.newPlot('myDiv', data, layout);
              &lt;/script&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  ''')
  </code></pre>
  
  <p>The error message is: </p>
  
  <blockquote>
    <p>ReferenceError: Plotly is not defined
        at eval (eval at globalEval (jquery.min.js:2), :21:17)
        at eval ()
        at Function.globalEval (jquery.min.js:2)
        at ua (jquery.min.js:3)
        at n.fn.init.append (jquery.min.js:3)
        at OutputArea._safe_append (outputarea.js:456)
        at OutputArea.append_execute_result (outputarea.js:493)
        at OutputArea.append_output (outputarea.js:326)
        at OutputArea.handle_output (outputarea.js:257)
        at output (codecell.js:382)</p>
  </blockquote>