position_jitter#
- position_jitter(width=None, height=None, seed=None)#
Adjust position by assigning random noise to points. Better for discrete values.
- Parameters:
- widthfloat
Jittering width. The value of width is relative and typically ranges between 0 and 0.5. Values that are greater than 0.5 lead to overlapping of the points.
- heightfloat
Jittering height. The value of height is relative and typically ranges between 0 and 0.5. Values that are greater than 0.5 lead to overlapping of the points.
- seedint
A random seed to make the jitter reproducible. If None (the default value), the seed is initialised with a random value.
- Returns:
- FeatureSpec
Geom object position specification.
Notes
Adjust position by dodging overlaps to the side.
Examples
1import numpy as np 2from lets_plot import * 3LetsPlot.setup_html() 4n = 100 5np.random.seed(42) 6x = np.random.randint(4, size=n) 7y = np.random.randint(3, size=n) 8c = np.char.add(x.astype(str), y.astype(str)) 9ggplot({'x': x, 'y': y, 'c': c}, aes('x', 'y')) + \ 10 geom_point(aes(fill='c'), show_legend=False, \ 11 size=8, alpha=.5, shape=21, color='black', \ 12 position=position_jitter(width=.2, height=.2, seed=42))