Repository: bokeh/bokeh

Issue:
glyphs.py server issue - plots appearing twice
I'm seeing some weird behavior on `examples/plotting/server/glyphs.py`

I modified the code slightly to only display the scatter plots. Here's the code and at the bottom a very zoomed out version of the screenshot:

``` python
# The plot server must be running
# Go to http://localhost:5006/bokeh to view this plot

import numpy as np

from bokeh.plotting import figure, show, output_server, vplot

N = 9

x = np.linspace(-2, 2, N)
y = x**2
sizes = np.linspace(10, 20, N)

xpts = np.array([-.09, -.12, .0, .12, .09])
ypts = np.array([-.1, .02, .1, .02, -.1])

output_server("glyphs")

vplot = vplot()

p = figure(width=200, height=200, title="wedge")
p.wedge(x, y, 15, 0.6, 4.1, radius_units="screen", color="#B3DE69")
vplot.children.append(p)

p = figure(width=200, height=200, title="circle_x")
p.scatter(x, y, marker="circle_x", size=sizes, color="#DD1C77", fill_color=None)
vplot.children.append(p)

p = figure(width=200, height=200, title="triangle")
p.scatter(x, y, marker="triangle", size=sizes, color="#99D594", line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="circle")
p.scatter(x, y, marker="o", size=sizes, color="#80B1D3", line_width=3)
vplot.children.append(p)

p = figure(width=200, height=200, title="cross")
p.scatter(x, y, marker="cross", size=sizes, color="#E6550D", line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="diamond")
p.scatter(x, y, marker="diamond", size=sizes, color="#1C9099", line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="inverted_triangle")
p.scatter(x, y, marker="inverted_triangle", size=sizes, color="#DE2D26")
vplot.children.append(p)

p = figure(width=200, height=200, title="square_x")
p.scatter(x, y, marker="square_x", size=sizes, color="#FDAE6B",
    fill_color=None, line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="asterisk")
p.scatter(x, y, marker="asterisk", size=sizes, color="#F0027F", line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="square_cross")
p.scatter(x, y, marker="square_cross", size=sizes, color="#7FC97F",
    fill_color=None, line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="diamond_cross")
p.scatter(x, y, marker="diamond_cross", size=sizes, color="#386CB0",
    fill_color=None, line_width=2)
vplot.children.append(p)

p = figure(width=200, height=200, title="circle_cross")
p.scatter(x, y, marker="circle_cross", size=sizes, color="#FB8072",
    fill_color=None, line_width=2)
vplot.children.append(p)

show(vplot)  # open a browser
```

<img width="1392" alt="screen shot 2015-11-04 at 7 58 36 pm" src="https://cloud.githubusercontent.com/assets/1796208/10959562/eee93ae0-832e-11e5-8595-f5572d419812.png">



Discussion:
i should add that i ran this but running a bokeh server `./bin/bokeh serve` and then running `python glyphs.py` from the `examples/plotting/server/` directory.

if i try running `./bin/bokeh serve examples/plotting/server/glyphs.py` then i get the following error message when I try and load http://localhost:5006/glyphs

``` sh
ERROR:bokeh.application.application:Error running application handler <bokeh.application.spellings.script.ScriptHandler object at 0x106f83518>: 'not all arguments converted during string formatting\nFile "script.py", line 51, in complainer:\n" %s() call." % (self._path, name, name, name),' 'Traceback (most recent call last):\n  File "/Users/caged/Dev/bokeh/bokeh/bokeh/application/spellings/script.py", line 81, in modify_document\n    exec(self._code, self._module.__dict__)\n  File "/Users/caged/Dev/bokeh/bokeh/examples/plotting/server/glyphs.py", line 17, in <module>\n    output_server("glyphs")\n  File "/Users/caged/Dev/bokeh/bokeh/bokeh/application/spellings/script.py", line 51, in complainer\n    " %s() call." % (self._path, name, name, name),\nTypeError: not all arguments converted during string formatting\n'
```


Resolving patch:
diff --git a/bokeh/application/spellings/script.py b/bokeh/application/spellings/script.py
--- a/bokeh/application/spellings/script.py
+++ b/bokeh/application/spellings/script.py
@@ -7,6 +7,7 @@
 from bokeh.io import set_curdoc, curdoc
 import codecs
 
+
 class ScriptHandler(SpellingHandler):
     """Run a script which modifies a Document"""
 
@@ -46,10 +47,10 @@ def url_path(self):
 
     def _make_io_complainer(self, name):
         def complainer(*args, **kwargs):
-            print("%s: Warning: call to %s() should not be needed in scripts run by the 'bokeh'" +
-                  " command, try running this with 'python' or remove the call to %s(). Ignoring" +
-                  " %s() call." % (self._path, name, name, name),
-                  file=sys.stderr)
+            print("""
+    %s: Warning: call to %s() should not be needed in scripts run by the 'bokeh'
+    command, try running this with 'python' or remove the call to %s(). Ignoring
+    %s() call.""" % (self._path, name, name, name), file=sys.stderr)
         return complainer
 
     # monkeypatching is a little ugly, but in this case there's no reason any legitimate
@@ -94,4 +95,3 @@ def modify_document(self, doc):
             self._error = "%s\nFile \"%s\", line %d, in %s:\n%s" % (str(e), os.path.basename(filename), line_number, func, txt)
         finally:
             self._unmonkeypatch_io(old_io)
-
diff --git a/examples/plotting/server/glyphs.py b/examples/plotting/server/glyphs.py
--- a/examples/plotting/server/glyphs.py
+++ b/examples/plotting/server/glyphs.py
@@ -1,9 +1,10 @@
-# The plot server must be running
-# Go to http://localhost:5006/bokeh to view this plot
+# The plot server must be running (./bin/bokeh serve)
+# Running python glyphs.py will open the plot in the browser
 
 import numpy as np
 
-from bokeh.plotting import figure, show, output_server, vplot
+from bokeh.plotting import figure
+from bokeh.io import show, output_server, vplot
 
 N = 9
 
@@ -16,129 +17,119 @@
 
 output_server("glyphs")
 
-vplot = vplot()
+plots = []
 
 p = figure(title="annular_wedge")
-p.annular_wedge(x, y, 10, 20, 0.6, 4.1, color="#8888ee",
-    inner_radius_units="screen", outer_radius_units="screen")
-vplot.children.append(p)
+p.annular_wedge(x, y, 10, 20, 0.6, 4.1, color="#8888ee", inner_radius_units="screen", outer_radius_units="screen")
+plots.append(p)
 
-p = figure(title="annular_wedge")
-p.annulus(x, y, 10, 20, color="#7FC97F",
-    inner_radius_units="screen", outer_radius_units = "screen")
-vplot.children.append(p)
+p = figure(title="annulus")
+p.annulus(x, y, 10, 20, color="#7FC97F", inner_radius_units="screen", outer_radius_units = "screen")
+plots.append(p)
 
 p = figure(title="arc")
-p.arc(x, y, 20, 0.6, 4.1,
-    radius_units="screen", color="#BEAED4", line_width=3)
-vplot.children.append(p)
+p.arc(x, y, 20, 0.6, 4.1, radius_units="screen", color="#BEAED4", line_width=3)
+plots.append(p)
 
 p = figure(title="bezier")
-p.bezier(x, y, x+0.2, y, x+0.1, y+0.1, x-0.1, y-0.1,
-    color="#D95F02", line_width=2)
-vplot.children.append(p)
+p.bezier(x, y, x+0.2, y, x+0.1, y+0.1, x-0.1, y-0.1, color="#D95F02", line_width=2)
+plots.append(p)
 
 p = figure(title="circle")
 p.circle(x, y, radius=0.1, color="#3288BD")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="line")
 p.line(x, y, color="#F46D43")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="multi_line")
-p.multi_line([xpts+xx for xx in x], [ypts+yy for yy in y],
-    color="#8073AC", line_width=2)
-vplot.children.append(p)
+p.multi_line([xpts+xx for xx in x], [ypts+yy for yy in y], color="#8073AC", line_width=2)
+plots.append(p)
 
 p = figure(title="oval")
 p.oval(x, y, 15, 25, angle=-0.7, color="#1D91C0",
     width_units="screen", height_units="screen")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="patch")
 p.patch(x, y, color="#A6CEE3")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="patches")
 p.patches([xpts+xx for xx in x], [ypts+yy for yy in y], color="#FB9A99")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="quad")
 p.quad(x, x-0.1, y, y-0.1, color="#B3DE69")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="quadratic")
 p.quadratic(x, y, x+0.2, y, x+0.1, y+0.1, color="#4DAF4A", line_width=3)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="ray")
 p.ray(x, y, 45, -0.7, color="#FB8072", line_width=2)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="rect")
-p.rect(x, y, 10, 20, color="#CAB2D6",
-    width_units="screen", height_units="screen")
-vplot.children.append(p)
+p.rect(x, y, 10, 20, color="#CAB2D6", width_units="screen", height_units="screen")
+plots.append(p)
 
 p = figure(title="segment")
 p.segment(x, y, x-0.1, y-0.1, color="#F4A582", line_width=3)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="square")
 p.square(x, y, size=sizes, color="#74ADD1")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="wedge")
 p.wedge(x, y, 15, 0.6, 4.1, radius_units="screen", color="#B3DE69")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="circle_x")
 p.scatter(x, y, marker="circle_x", size=sizes, color="#DD1C77", fill_color=None)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="triangle")
 p.scatter(x, y, marker="triangle", size=sizes, color="#99D594", line_width=2)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="circle")
 p.scatter(x, y, marker="o", size=sizes, color="#80B1D3", line_width=3)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="cross")
 p.scatter(x, y, marker="cross", size=sizes, color="#E6550D", line_width=2)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="diamond")
 p.scatter(x, y, marker="diamond", size=sizes, color="#1C9099", line_width=2)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="inverted_triangle")
 p.scatter(x, y, marker="inverted_triangle", size=sizes, color="#DE2D26")
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="square_x")
-p.scatter(x, y, marker="square_x", size=sizes, color="#FDAE6B",
-    fill_color=None, line_width=2)
-vplot.children.append(p)
+p.scatter(x, y, marker="square_x", size=sizes, color="#FDAE6B", fill_color=None, line_width=2)
+plots.append(p)
 
 p = figure(title="asterisk")
 p.scatter(x, y, marker="asterisk", size=sizes, color="#F0027F", line_width=2)
-vplot.children.append(p)
+plots.append(p)
 
 p = figure(title="square_cross")
-p.scatter(x, y, marker="square_cross", size=sizes, color="#7FC97F",
-    fill_color=None, line_width=2)
-vplot.children.append(p)
+p.scatter(x, y, marker="square_cross", size=sizes, color="#7FC97F", fill_color=None, line_width=2)
+plots.append(p)
 
 p = figure(title="diamond_cross")
-p.scatter(x, y, marker="diamond_cross", size=sizes, color="#386CB0",
-    fill_color=None, line_width=2)
-vplot.children.append(p)
+p.scatter(x, y, marker="diamond_cross", size=sizes, color="#386CB0", fill_color=None, line_width=2)
+plots.append(p)
 
 p = figure(title="circle_cross")
-p.scatter(x, y, marker="circle_cross", size=sizes, color="#FB8072",
-    fill_color=None, line_width=2)
-vplot.children.append(p)
+p.scatter(x, y, marker="circle_cross", size=sizes, color="#FB8072", fill_color=None, line_width=2)
+plots.append(p)
 
-show(vplot)  # open a browser
+show(vplot(*plots))  # open a browser


Test patch: