Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tools option to declare list of tools #120

Merged
merged 3 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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