Skip to content

Commit

Permalink
Add tools option to declare list of tools (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Nov 29, 2018
1 parent 9ee63d2 commit 3af8786
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/user_guide/Plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@
"- ``loglog`` (default=False): Enables logarithmic x- and y-axis\n",
"- ``shared_axes`` (default=False): Whether to link axes between plots\n",
"- ``title`` (default=''): Title for the plot\n",
"- ``tools`` (default=[]): List of tool instances or strings (e.g. ['tap', box_select'])\n",
"- ``xformatter``/``yformatter`` (default=None): Formatter for the x-axis and y-axis (accepts printf formatter, e.g. '%.3f', and bokeh TickFormatter)\n",
"- ``xlabel``/``ylabel`` (default=None): Axis labels for the x-axis and y-axis\n",
"- ``xlim``/``ylim`` (default=None): Plot limits of the x- and y-axis\n",
Expand Down
11 changes: 8 additions & 3 deletions hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
import numpy as np

from bokeh.models import HoverTool
from holoviews.core.dimension import Dimension
from holoviews.core.spaces import DynamicMap, HoloMap, Callable
from holoviews.core.overlay import NdOverlay
Expand Down Expand Up @@ -143,7 +144,7 @@ def __init__(self, data, x, y, kind=None, by=None, use_index=True,
precompute=False, flip_xaxis=False, flip_yaxis=False,
dynspread=False, hover_cols=[], x_sampling=None,
y_sampling=None, project=False, xlabel=None, ylabel=None,
xformatter=None, yformatter=None, **kwds):
xformatter=None, yformatter=None, tools=[], **kwds):

# Process data and related options
self._process_data(kind, data, x, y, by, groupby, row, col,
Expand Down Expand Up @@ -235,8 +236,12 @@ def __init__(self, data, x, y, kind=None, by=None, use_index=True,
if rot:
axis = 'yrotation' if invert else 'xrotation'
plot_opts[axis] = rot
if hover:
plot_opts['tools'] = ['hover']

tools = list(tools)
if hover and not any(t for t in tools if isinstance(t, HoverTool)
or t == 'hover'):
tools.append('hover')
plot_opts['tools'] = tools

if self.crs and global_extent:
plot_opts['global_extent'] = global_extent
Expand Down

0 comments on commit 3af8786

Please sign in to comment.