What is a fast and proper way to refresh/update plots in Bokeh (0.11) server app? : <p>I have a bokeh (v0.11) serve app that produces a scatter plot using (x,y) coordinates from a data frame. I want to add interactions such that when a user either selects points on the plot or enters the name of comma-separated points in the text box (ie. "p55, p1234"), then those points will turn red on the scatter plot. </p>

<p>I have found one way to accomplish this (Strategy #3, below) but it is terribly slow for large dataframes. I would think there is a better method. Can anyone help me out? Am I missing some obvious function call?</p>

<ul>
<li><strong>Strategy 1</strong> (&lt;1ms for 100 points) drills into the ColumnDataSource data for the exist plot and attempts to change the selected points. </li>
<li><strong>Strategy 2</strong> (~70ms per 100 points) overwrites the plot's existing ColumnDataSource with a newly created ColumnDataSource.  </li>
<li><strong>Strategy 3</strong> (~400ms per 100 points) is Strategy 2 and then it re-creates
the figure.</li>
</ul>

<p>Code is deposited on pastebin: <a href="http://pastebin.com/JvQ1UpzY">http://pastebin.com/JvQ1UpzY</a> Most relevant portion is copied below.</p>

<pre><code>def refresh_graph(self, selected_points=None, old_idxs=None, new_idxs=None):
    # Strategy 1: Cherry pick current plot's source.
    # Compute time for 100 points: &lt; 1ms.
    if self.strategy == 1:
        t1 = datetime.now()
        for idx in old_idxs:
            self.graph_plot.data_source.data['color'][idx] = 'steelblue'
        for idx in new_idxs:
            self.graph_plot.data_source.data['color'][idx] = 'red'
        print('Strategy #1 completed in {}'.format(datetime.now() - t1))
    else:
        t3 = datetime.now()
        self.coords['color'] = 'steelblue'
        self.coords.loc[selected_points, 'color'] = 'red'
        new_source = bkmodels.ColumnDataSource(self.coords)
        self.graph_plot = self.graph_fig.scatter('x', 'y', source=new_source, color='color', alpha=0.6)
        print('Strategy #3 completed in {}'.format(datetime.now() - t3))
    return
</code></pre>

<p>Ideally, I would like to be able to use <strong>Strategy #1</strong>, but it does not seem to allow the points to refresh within the client browser.</p>

<p>Thanks for any help!</p>

<p>FYI: I am using RHEL 6.X</p>
