Skip to content

Commit

Permalink
Add nan filter for histogrammy plots
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanjohnharris committed Apr 26, 2024
1 parent 7d9e25d commit 2693b12
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
label_size = 20,
label_formatter = bar_label_formatter,
linestyle = :solid,
fillalpha = 0.2)
fillalpha = 0.2,
filternan = true)
end

function Makie.plot!(plot::Ziggurat)
Expand All @@ -29,9 +30,12 @@ function Makie.plot!(plot::Ziggurat)
x = x == automatic ? y : x
isnothing(a) ? x : (x, a)
end
hist!(plot, plot.values; plot.attributes..., color = fillcolor,
values = lift(plot.attributes[:filternan], plot.values) do filternan, v
filternan ? filter(!isnan, v) : v
end
hist!(plot, values; plot.attributes..., color = fillcolor,
strokewidth = plot.attributes[:fillstrokewidth])
stephist!(plot, plot.values; plot.attributes...)
stephist!(plot, values; plot.attributes...)
plot
end

Expand All @@ -52,7 +56,8 @@ end
weights = automatic,
cycle = [:color => :patchcolor],
inspectable = theme(scene, :inspectable),
fillalpha = 0.2)
fillalpha = 0.2,
filternan = true)
end

function Makie.plot!(plot::Hill)
Expand All @@ -63,7 +68,10 @@ function Makie.plot!(plot::Hill)
plot.attributes[:fillalpha]) do x, a
isnothing(a) ? x : (x, a)
end
density!(plot, plot.values; plot.attributes..., color = fillcolor,
values = lift(plot.attributes[:filternan], plot.values) do filternan, v
filternan ? filter(!isnan, v) : v
end
density!(plot, values; plot.attributes..., color = fillcolor,
strokecolor)
plot
end

0 comments on commit 2693b12

Please sign in to comment.