Repository: bokeh/bokeh

Issue:
ability to remove tools from plot generated by mpl.to_bokeh
When a bokeh plot is developed from the mpl.to_bokeh function it comes with the default set of tools. There doesn't appear to be a mechanism to then remove tools and the function doesn't provide a means to give a parameter defining tools to include that are different than the defaults.

Here is some example code:

```
from bokeh import mpl
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0,10,0.1)
y = np.sin(x)

plt.plot(x,y)

fig = plt.gcf()

my_bokeh_fig = mpl.to_bokeh(fig=fig)
my_bokeh_fig.add_tools(HoverTool())
show(my_bokeh_fig)
```

and the generated figure:
<img width="447" alt="screen shot 2016-10-07 at 3 36 36 pm" src="https://cloud.githubusercontent.com/assets/4332322/19207253/e48d0aac-8ca3-11e6-8a2b-81f98368ea48.png">

I just saw @birdsarah give a great talk at BIDS and she suggested that I raise this as an issue.



Discussion:
Hi,

Plot have a .tools property you can modify at will:

```
In [4]: my_bokeh_fig.tools
Out[4]:
[PanTool(id='72f97788-3c82-4c84-bb78-1ec949fcc66d', ...),
 WheelZoomTool(id='f1f2d51c-70f5-4cbd-907a-6cc8516cd995', ...),
 BoxZoomTool(id='bbb87626-7901-4e01-95df-778dc7a60787', ...),
 SaveTool(id='4fb4a91f-7920-494b-939d-41db528420e0', ...),
 ResetTool(id='5ac37c35-18c4-4038-9f31-c8669e724271', ...),
 HelpTool(id='3ee0b9fe-55da-4cd6-bb38-73c79d9dadca', ...)]

In [5]: del my_bokeh_fig.tools[2]

In [6]: my_bokeh_fig.tools
Out[6]:
[PanTool(id='72f97788-3c82-4c84-bb78-1ec949fcc66d', ...),
 WheelZoomTool(id='f1f2d51c-70f5-4cbd-907a-6cc8516cd995', ...),
 SaveTool(id='4fb4a91f-7920-494b-939d-41db528420e0', ...),
 ResetTool(id='5ac37c35-18c4-4038-9f31-c8669e724271', ...),
 HelpTool(id='3ee0b9fe-55da-4cd6-bb38-73c79d9dadca', ...)]

In [7]: show(my_bokeh_fig)
```

The resulting plot has no box zoom.

Great. Thanks.

@bryevdv, what do you think about allowing user to pass tools string to `mpl.to_bokeh(fig=fig)`

so it could be `mpl.to_bokeh(fig=fig, tools='')`

I don't think it's going to be a particularly high priority for core devs, especially since you've shown a workaround, but I still think it'd be helpful.

Sure


Resolving patch:
diff --git a/bokeh/core/compat/bokeh_renderer.py b/bokeh/core/compat/bokeh_renderer.py
--- a/bokeh/core/compat/bokeh_renderer.py
+++ b/bokeh/core/compat/bokeh_renderer.py
@@ -41,10 +41,11 @@
 
 class BokehRenderer(Renderer):
 
-    def __init__(self, use_pd, xkcd):
+    def __init__(self, tools, use_pd, xkcd):
         "Initial setup."
         self.fig = None
         self.use_pd = use_pd
+        self.tools = tools
         self.xkcd = xkcd
         self.zorder = {}
         self.handles = {}
@@ -61,7 +62,7 @@ def open_figure(self, fig, props):
     def close_figure(self, fig):
         "Complete the plot: add tools."
         # Add tools
-        tool_objs, tools_map = _process_tools_arg(self.plot, DEFAULT_TOOLS)
+        tool_objs, tools_map = _process_tools_arg(self.plot, self.tools)
         self.plot.add_tools(*tool_objs)
 
         # Simple or Grid plot setup
diff --git a/bokeh/core/compat/mpl.py b/bokeh/core/compat/mpl.py
--- a/bokeh/core/compat/mpl.py
+++ b/bokeh/core/compat/mpl.py
@@ -15,6 +15,8 @@
 
 import matplotlib.pyplot as plt
 
+from ...plotting import DEFAULT_TOOLS
+
 from .bokeh_exporter import BokehExporter
 from .bokeh_renderer import BokehRenderer
 
@@ -22,7 +24,7 @@
 # Classes and functions
 #-----------------------------------------------------------------------------
 
-def to_bokeh(fig=None, use_pandas=True, xkcd=False):
+def to_bokeh(fig=None, tools=DEFAULT_TOOLS, use_pandas=True, xkcd=False):
     """ Uses bokeh to display a Matplotlib Figure.
 
     You can store a bokeh plot in a standalone HTML file, as a document in
@@ -49,7 +51,7 @@ def to_bokeh(fig=None, use_pandas=True, xkcd=False):
     if fig is None:
         fig = plt.gcf()
 
-    renderer = BokehRenderer(use_pandas, xkcd)
+    renderer = BokehRenderer(tools, use_pandas, xkcd)
     exporter = BokehExporter(renderer)
 
     exporter.run(fig)
diff --git a/examples/compat/mpl_stem.py b/examples/compat/mpl_stem.py
--- a/examples/compat/mpl_stem.py
+++ b/examples/compat/mpl_stem.py
@@ -13,4 +13,4 @@
 
 output_file("mpl_stem.html", title="mpl_stem.py example")
 
-show(mpl.to_bokeh())
+show(mpl.to_bokeh(tools='pan, wheel_zoom, crosshair'))


Test patch: