Skip to content

Commit

Permalink
Added jitter plot option for bokeh ScatterPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 3, 2017
1 parent b7ec70f commit e56208e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from bokeh.models import (CategoricalColorMapper, CustomJS, HoverTool,
FactorRange, Whisker, Band, Range1d)
from bokeh.models.tools import BoxSelectTool
from bokeh.transform import jitter

from ...core import Dataset, OrderedDict
from ...core.dimension import Dimension
Expand Down Expand Up @@ -34,6 +35,9 @@ class PointPlot(LegendPlot, ColorbarPlot):
Determines whether the `scaling_factor` should be applied to
the width or area of each point (default: "area").""")

jitter = param.Number(default=None, bounds=(0, None), doc="""
The amount of jitter to apply to offset the points along the x-axis.""")

scaling_factor = param.Number(default=1, bounds=(0, None), doc="""
Scaling factor which is applied to either the width or area
of each point, depending on the value of `scaling_method`.""")
Expand Down Expand Up @@ -91,6 +95,11 @@ def get_data(self, element, ranges, style):
data.update(sdata)
mapping.update(smapping)

if self.jitter:
axrange = 'y_range' if self.invert_axes else 'x_range'
mapping['x'] = jitter(dims[xidx], self.jitter,
range=self.handles[axrange])

self._get_hover_data(data, element)
return data, mapping, style

Expand Down

0 comments on commit e56208e

Please sign in to comment.