Open jdm204 opened 3 years ago
@kimlaberinto created a function for this:
function create_jitter_array(length_data_array; jitter_width = 0.1, clamped_portion = 0.1)
jitter_width < 0 && ArgumentError("`jitter_width` should be positive.")
!(0 <= clamped_portion <= 1) || ArgumentError("`clamped_portion` should be between 0.0 to 1.0")
# Make base jitter, note base jitter minimum-to-maximum span is 1.0
base_min, base_max = (-0.5, 0.5)
jitter = [rand_localized(base_min, base_max) for _ in 1:length_data_array]
# created clamp_min, and clamp_max to clamp a portion of the data
@assert (base_max - base_min) == 1.0
@assert (base_max + base_min) / 2.0 == 0
clamp_min = base_min + (clamped_portion / 2.0)
clamp_max = base_max - (clamped_portion / 2.0)
# clamp if need be
clamp!(jitter, clamp_min, clamp_max)
# Based on assumptions of clamp_min and clamp_max above
jitter = jitter * (jitter_width / clamp_max)
return jitter
end
Maybe we can figure out how to upstream these... This was for a raincloud plot recipe, which might as well live in Makie itself...
Just to support this request - in ggbeeswarm there are some nice examples what to use as the randomization function.
I personally have a strong preference for "quasirandom" - but no idea on the implementation side.
Taken from: https://cran.r-project.org/web/packages/ggbeeswarm/vignettes/usageExamples.pdf
Just found out, Gadfly has beeswarm, maybe helpful. https://github.com/GiovineItalia/Gadfly.jl/blob/0bec09d30eca618e10c64fe383024211629c0c65/src/geom/beeswarm.jl#L10-L17
This feature would be nice!
If you come here via google: https://github.com/MakieOrg/SwarmMakie.jl
Can be closed.
AlgebraOfGraphics is very nice!
I was wondering if support for jitter is planned, i.e. adding a bit of randomness to the positions of scatter points to help with overplotting.
For example, when plotting continuous data (y) against categorical (x) it can be nice to jitter the points in the horizontal x direction:
In ggplot2 for example this is implemented as parameters to the point visual and by a jitter visual like
geom_jitter(width=0.4, height=0)
.