Skip to content

Commit b1fceca

Browse files
authored
fix histogram using ranges (#5635)
1 parent 9de3998 commit b1fceca

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

PlotsBase/src/recipes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,11 @@ _hist_edges(
770770
_hist_norm_mode(mode::Symbol) = mode
771771
_hist_norm_mode(mode::Bool) = mode ? :pdf : :none
772772

773+
_invertedindex(v, not) = [j for (i, j) in enumerate(v) if !(i not)]
774+
773775
_filternans(vs::NTuple{1, AbstractVector}) = filter!.(isfinite, vs)
776+
_filternans(vs::NTuple{1, AbstractRange}) = filter!.(isfinite, collect.(vs))
774777
function _filternans(vs::NTuple{N, AbstractVector}) where {N}
775-
_invertedindex(v, not) = [j for (i, j) in enumerate(v) if !(i not)]
776778
nots = union(Set.(findall.(!isfinite, vs))...)
777779
return _invertedindex.(vs, Ref(nots))
778780
end

PlotsBase/test/test_recipes.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ using OffsetArrays
66
legend --> :topleft
77
(1:3, 1:3)
88
end
9-
let pl = pl = plot(LegendPlot(); legend = :right)
9+
let pl = plot(LegendPlot(); legend = :right)
1010
@test pl[1][:legend_position] :right
1111
end
12-
let pl = pl = plot(LegendPlot())
12+
let pl = plot(LegendPlot())
1313
@test pl[1][:legend_position] :topleft
1414
end
1515
let pl = plot(LegendPlot(); legend = :inline)
@@ -53,9 +53,9 @@ end
5353

5454
@testset "steps offset" begin
5555
data = OffsetArray(rand(11), -5:5)
56-
plot(data, linetype = :steppre)
57-
plot(data, linetype = :stepmid)
58-
plot(data, linetype = :steppost)
56+
@test_nowarn plot(data, linetype = :steppre)
57+
@test_nowarn plot(data, linetype = :stepmid)
58+
@test_nowarn plot(data, linetype = :steppost)
5959
end
6060

6161
@testset "offset axes" begin
@@ -155,4 +155,8 @@ with(:gr) do
155155
@test_nowarn show(devnull, bar([1 2 3], [0.02 125 10_000]; yscale = :log10))
156156
@test_nowarn histogram(randn(100), yscale = :log10)
157157
end
158+
159+
@testset "histogram range" begin
160+
@test histogram(1:10) isa Plot
161+
end
158162
end

0 commit comments

Comments
 (0)