|
5 | 5 | from bokeh.models import (CategoricalColorMapper, CustomJS, HoverTool,
|
6 | 6 | FactorRange, Whisker, Band, Range1d)
|
7 | 7 | from bokeh.models.tools import BoxSelectTool
|
| 8 | +from bokeh.transform import jitter |
8 | 9 |
|
9 | 10 | from ...core import Dataset, OrderedDict
|
10 | 11 | from ...core.dimension import Dimension
|
@@ -34,6 +35,9 @@ class PointPlot(LegendPlot, ColorbarPlot):
|
34 | 35 | Determines whether the `scaling_factor` should be applied to
|
35 | 36 | the width or area of each point (default: "area").""")
|
36 | 37 |
|
| 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 | + |
37 | 41 | scaling_factor = param.Number(default=1, bounds=(0, None), doc="""
|
38 | 42 | Scaling factor which is applied to either the width or area
|
39 | 43 | of each point, depending on the value of `scaling_method`.""")
|
@@ -91,6 +95,11 @@ def get_data(self, element, ranges, style):
|
91 | 95 | data.update(sdata)
|
92 | 96 | mapping.update(smapping)
|
93 | 97 |
|
| 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 | + |
94 | 103 | self._get_hover_data(data, element)
|
95 | 104 | return data, mapping, style
|
96 | 105 |
|
|
0 commit comments