Skip to content

Commit

Permalink
Fixed a small bug with attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCedarPrince committed Mar 12, 2024
1 parent 19c4d88 commit 8e8bde4
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ function Makie.plot!(plot::Beeswarm)
end
notify(final_widths)

#=
BUG: For some reason, the recipe is not respecting inputs for these new kwargs I defined.
I am sure I am doing something wrong with the recipe, but as of now, I have made the
kwarg values constant.
=#

gutter = .4
gutter_threshold = .55

# set up buffers
point_buffer = Observable{Vector{Point2f}}(zeros(Point2f, length(positions[])))
pixelspace_point_buffer = Observable{Vector{Point2f}}(zeros(Point2f, length(positions[])))
Expand All @@ -128,7 +117,7 @@ function Makie.plot!(plot::Beeswarm)
# Method to create a gutter when a gutter is defined
# NOTE: Maybe turn this into a helper function?

if !isnothing(gutter)
if !isnothing(plot.attributes[:gutter].val)
# Get category labels
groups = [pt[1] for pt in positions]

Expand All @@ -146,17 +135,17 @@ function Makie.plot!(plot::Beeswarm)
ending = findlast(==(group), groups)

# Calculate a gutter threshold
gutter_threshold_count = (ending - starting) * gutter_threshold
gutter_threshold_count = (ending - starting) * plot.attributes[:gutter_threshold].val
gutter_pts = 0
for pt in point_buffer.val[starting:ending]
# Check if a point values between a acceptable range
if pt[1] > (group + gutter) || pt[1] < (group - gutter)
if pt[1] > (group + plot.attributes[:gutter].val) || pt[1] < (group - plot.attributes[:gutter].val)
if pt[1] < 0
# Left side of the gutter
point_buffer.val[idx] = Point2f(group - gutter, pt[2])
point_buffer.val[idx] = Point2f(group - plot.attributes[:gutter].val, pt[2])
else
# Right side of the gutter
point_buffer.val[idx] = Point2f(group + gutter, pt[2])
point_buffer.val[idx] = Point2f(group + plot.attributes[:gutter].val, pt[2])
end
gutter_pts += 1
end
Expand All @@ -179,6 +168,8 @@ function Makie.plot!(plot::Beeswarm)
pop!(attrs, :algorithm)
pop!(attrs, :side)
pop!(attrs, :direction)
pop!(attrs, :gutter)
pop!(attrs, :gutter_threshold)
# pop!(attrs, :space)
attrs[:space] = :data
attrs[:markerspace] = :pixel
Expand Down

0 comments on commit 8e8bde4

Please sign in to comment.