Skip to content

Commit

Permalink
Merge pull request #36 from MrTomRod/master
Browse files Browse the repository at this point in the history
add optional argument to define bokeh tools, removed print statement
  • Loading branch information
veghp committed Apr 26, 2020
2 parents 2fe5671 + 8f7fcbf commit 30cff7b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dna_features_viewer/GraphicRecord/BokehPlottableMixin.py
Expand Up @@ -51,7 +51,7 @@ def bokeh_feature_patch(
result.update(kwargs)
return result

def plot_with_bokeh(self, figure_width=5, figure_height="auto"):
def plot_with_bokeh(self, figure_width=5, figure_height="auto", tools="auto"):
"""Plot the graphic record using Bokeh.
Examples
Expand All @@ -66,6 +66,10 @@ def plot_with_bokeh(self, figure_width=5, figure_height="auto"):
if not PANDAS_AVAILABLE:
raise ImportError("``plot_with_bokeh`` requires Pandas installed.")

# Set up default tools
if tools == "auto":
tools = [HoverTool(tooltips="@hover_html"), "xpan,xwheel_zoom,reset,tap"]

# FIRST PLOT WITH MATPLOTLIB AND GATHER INFOS ON THE PLOT
ax, (features_levels, plot_data) = self.plot(figure_width=figure_width)
width, height = [int(100 * e) for e in ax.figure.get_size_inches()]
Expand All @@ -75,18 +79,17 @@ def plot_with_bokeh(self, figure_width=5, figure_height="auto"):
else:
height = 100 * figure_height
height = max(height, 185) # Minimal height to see all icons
print (height)

max_y = max(
[data["annotation_y"] for f, data in plot_data.items()]
+ list(features_levels.values())
)

# BUILD THE PLOT ()
hover = HoverTool(tooltips="@hover_html")
plot = figure(
plot_width=width,
plot_height=height,
tools=[hover, "xpan,xwheel_zoom,reset,tap"],
tools=tools,
x_range=Range1d(0, self.sequence_length),
y_range=Range1d(-1, max_y + 1),
)
Expand Down

0 comments on commit 30cff7b

Please sign in to comment.