Repository: bokeh/bokeh

Issue:
Multi-document plots.
Shouldn't issuing output_server with new docname restart plotting. 
In the following program, I would expect the the server to show two documents ("line plot" and "hist") with a single plot each. I get the two documents but get both plots in the "hist" document. My target is to show sets of plots in different browser tabs instead on all plots in single page.

```
from bokeh.plotting import *
import numpy as np

N = 80
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)

output_server('line plot')
line(x,y, color="#0000FF", tools=['wheel_zoom','box_zoom'])
show()

output_server('hist')
figure(tools=['wheel_zoom','box_zoom'])
hist, edges = np.histogram(y)
quad(top=hist, bottom=np.zeros(len(hist)), left=edges[:-1], right=edges[1:])
show()
```



Discussion:
Current behavior is that when a connection is made to the server, whatever you have is merged with what the server has - this is done so that if someone starts plotting, then decides they want to use the server, they don't have their work wiped out.  In your case, you should be able to wipe out your in memory version before switching documents

not great, but `bokeh.plotting._default_document = bokeh.document.Document()` should do the trick

What do you think of this?  Open to suggestions, if you like it, I would probably add a reset function into plotting.py which does just this.

The given trick does works, though having the reset function would be a cleaner solution. 
My use case is real-time plotting, and I plan to separate the plotting into groups that are displayed in separate tabs in the browser. 

Is it not possible to mix various output_server, output_file? The following script gives JSON errors. The idea is to have intermediate plots drawn real-time on the server, and the final plot written to html file for possible later use.

``` javascript
import bokeh.plotting as plt
from bokeh.document import Document
import numpy as np

N = 80
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)

plt.output_server('intermediate plot1')
plt.line(x,y, color="#0000FF", tools=['wheel_zoom','box_zoom'])
plt.show()

plt._default_document = Document()
plt.output_server('intermediate plot2')
plt.figure(tools=['wheel_zoom','box_zoom'])
plt.line(x,y, color="black")
plt.show()

plt._default_document = Document()
plt.output_file('plot final.html', title='final hist')
plt.figure(tools=['wheel_zoom','box_zoom'])
hist, edges = np.histogram(y)
plt.quad(top=hist, bottom=np.zeros(len(hist)), left=edges[:-1], right=edges[1:])
plt.show()
```

@waqarmalik if it comes time to make this an application talk to us about it, I think we're exploring several approaches for making that part easier

In terms of multiple outputs - it should work, and if it doesn't it's a bug.  I'll take a look


Resolving patch:
diff --git a/bokeh/plotting.py b/bokeh/plotting.py
--- a/bokeh/plotting.py
+++ b/bokeh/plotting.py
@@ -65,6 +65,25 @@ def cursession():
     '''
     return _default_session
 
+def reset_output():
+    ''' Deactivate all currently active output modes.
+
+    Subsequent calls to show() will not render until a new output mode is
+    activated.
+
+    Returns:
+        None
+
+    '''
+    global _default_document
+    global _default_session
+    global _default_file
+    global _default_notebook
+    _default_document = Document()
+    _default_session = None
+    _default_file = None
+    _default_notebook = None
+
 def hold(value=True):
     ''' Set or clear the plot hold status on the current document.
 
@@ -221,7 +240,6 @@ def show(browser=None, new="tab", url=None):
     if not plot:
         warnings.warn("No current plot to show. Use renderer functions (circle, rect, etc.) to create a current plot (see http://bokeh.pydata.org/index.html)")
         return
-
     if notebook and session:
         import IPython.core.displaypub as displaypub
         push(session=session)
@@ -534,4 +552,3 @@ def load_object(obj):
     """updates object from the server
     """
     cursession().load_object(obj, curdoc())
-    


Test patch:
diff --git a/bokeh/tests/test_plotting.py b/bokeh/tests/test_plotting.py
new file mode 100644
--- /dev/null
+++ b/bokeh/tests/test_plotting.py
@@ -0,0 +1,18 @@
+import unittest
+
+import bokeh.plotting as plotting
+
+class TestPlotting(unittest.TestCase):
+
+    def test_reset_output(self):
+        plotting._default_document = 10
+        plotting._default_session = 10
+        plotting._default_file = 10
+        plotting._default_notebook = 10
+        plotting.reset_output()
+        self.assertTrue(isinstance(plotting._default_document, plotting.Document))
+        self.assertEqual(plotting._default_session, None)
+        self.assertEqual(plotting._default_file, None)
+        self.assertEqual(plotting._default_notebook, None)
+
+