Bokeh is behaving in mysterious way
<pre><code>import numpy as np
from bokeh.plotting import * 
from bokeh.models import ColumnDataSource
</code></pre>

<h1>prepare data</h1>

<pre><code>N = 300
x = np.linspace(0,4*np.pi, N)
y0 = np.sin(x)
y1 = np.cos(x)
output_notebook()

#create a column data source for the plots to share
source = ColumnDataSource(data = dict(x = x, y0 = y0, y1 = y1))

Tools = "pan, wheel_zoom, box_zoom, reset, save, box_select, lasso_select"
</code></pre>

<h1>create a new plot and add a renderer</h1>

<pre><code>left = figure(tools = Tools, plot_width = 350, plot_height = 350, title = 'sinx')
left.circle(x, y0,source = source )
</code></pre>

<h1>create another plot and add a renderer</h1>

<pre><code>right = figure(tools = Tools, plot_width = 350, plot_height = 350 , title = 'cosx')
right.circle(x, y1, source = source)
</code></pre>

<h1>put the subplot in gridplot and show the plot</h1>

<pre><code>p = gridplot([[left, right]])
show(p)
</code></pre>

<p><a href="http://i.stack.imgur.com/To6If.png" rel="nofollow"><img src="http://i.stack.imgur.com/To6If.png" alt="enter image description here"></a></p>

<p><strong>something is wrong with sin graph. Don't know why 'Bokeh' is behaving like this.But if I write y's into  Double or single quotation marks/inverted commas then things work fine</strong> </p>

<pre><code>left.circle(x, 'y0',source = source )

right.circle(x, 'y1', source = source)
</code></pre>

<h1>put the subplot in gridplot and show the plot</h1>

<pre><code>p = gridplot([[left, right]])
show(p)
</code></pre>

<p><a href="http://i.stack.imgur.com/OFNQh.png" rel="nofollow"><img src="http://i.stack.imgur.com/OFNQh.png" alt="enter image description here"></a></p>

<p>Things I tried to resolve the problem</p>

<p>1) Restarted my notebook . (Easiest way to solve problem)</p>

<p>2) Generated the output into new window.</p>

<p>3) Generated plot separately instead of grid plot.</p>

<p>Please help me out to find out the reason behind the scene. </p>

<p>Am I doing something wrong ?
Is it a bug ?</p>

<p>If you want to configure multiple glyphs to share data from a single <code>ColumnDataSource</code>, then you always need to configure the glyph properties with the <em>names</em> of the columns, and <strong><em>not</em></strong> with the actual data literals, as you have done. In other words:</p>

<pre><code>left.circle('x', 'y0',source = source )

right.circle('x', 'y1', source = source)
</code></pre>

<p>Note that I have quoted <code>'x'</code> as well. This is the correct way to do things when sharing a source. When you pass a literal value (i.e., a real list or array), glyphs functions like <code>.circle</code> automatically synthesize a column for you as a convenience. But they use defined names based on the property, so if you share a source between two renderers, then the second call to <code>.circle</code> will overwrite the column <code>'y'</code> column that the first call to <code>.circle</code> made. Which is exactly what you are seeing. </p>

<p>As you can imagine, this behavior is confusing. Accordingly, there is an <a href="https://github.com/bokeh/bokeh/issues/2056" rel="nofollow">open GitHub issue</a> to specifically and completely disallow passing in data literals whenever the <code>source</code> argument is provided explicitly. I can guarantee this will happen in the near future, so if you are sharing a source, you should always and only pass in <em>column names</em> (i.e. strings).</p>

python python-3.x debugging data-visualization bokeh