Skip to content

Commit 3d090d2

Browse files
authored
fix histogram using ranges (#5636)
1 parent 526c2ca commit 3d090d2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Plots/src/recipes.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,10 @@ _hist_edges(
776776
_hist_norm_mode(mode::Symbol) = mode
777777
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
778778

779+
_invertedindex(v, not) = [j for (i, j) in enumerate(v) if !(i not)]
779780
_filternans(vs::NTuple{1, AbstractVector}) = filter!.(isfinite, vs)
781+
_filternans(vs::NTuple{1, AbstractRange}) = filter!.(isfinite, collect.(vs))
780782
function _filternans(vs::NTuple{N, AbstractVector}) where {N}
781-
_invertedindex(v, not) = [j for (i, j) in enumerate(v) if !(i not)]
782783
nots = union(Set.(findall.(!isfinite, vs))...)
783784
return _invertedindex.(vs, Ref(nots))
784785
end

Plots/test/test_recipes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,8 @@ Plots.with(:gr) do
153153
@test_nowarn show(devnull, bar([1 2 3], [0.02 125 10_000]; yscale = :log10))
154154
@test_nowarn histogram(randn(100), yscale = :log10)
155155
end
156+
157+
@testset "histogram range" begin
158+
@test histogram(1:10) isa Plot
159+
end
156160
end

0 commit comments

Comments
 (0)