Skip to content

Commit e56208e

Browse files
committed
Added jitter plot option for bokeh ScatterPlot
1 parent b7ec70f commit e56208e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

holoviews/plotting/bokeh/chart.py

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from bokeh.models import (CategoricalColorMapper, CustomJS, HoverTool,
66
FactorRange, Whisker, Band, Range1d)
77
from bokeh.models.tools import BoxSelectTool
8+
from bokeh.transform import jitter
89

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

38+
jitter = param.Number(default=None, bounds=(0, None), doc="""
39+
The amount of jitter to apply to offset the points along the x-axis.""")
40+
3741
scaling_factor = param.Number(default=1, bounds=(0, None), doc="""
3842
Scaling factor which is applied to either the width or area
3943
of each point, depending on the value of `scaling_method`.""")
@@ -91,6 +95,11 @@ def get_data(self, element, ranges, style):
9195
data.update(sdata)
9296
mapping.update(smapping)
9397

98+
if self.jitter:
99+
axrange = 'y_range' if self.invert_axes else 'x_range'
100+
mapping['x'] = jitter(dims[xidx], self.jitter,
101+
range=self.handles[axrange])
102+
94103
self._get_hover_data(data, element)
95104
return data, mapping, style
96105

0 commit comments

Comments
 (0)