-
-
Notifications
You must be signed in to change notification settings - Fork 372
Description
histogram2d renders empty bins as transparent, which contrasts strongly with nearly-empty bins in colormaps where small is dark, including the default colormap:
x = Float64[]
let y = 0.0
for _=1:500
push!(x, y += randn() - 0.1y)
end
end
histogram2d([x[2:end]], [x[1:end-1]])

I would say this is a misleading representation of the data. This is much better:
histogram2d([x[2:end]], [x[1:end-1]], background="black")
It's worse when the distribution has spikes surrounded by zeros:
using Distributions
x = let n = 100_000
rand(Poisson(1),n) .* exp.(rand(n).*(2π*im)) .+ 0.1randn(n)
end
histogram2d(x)

The spike in the middle is barely visible. The distribution really looks like this:

I think the best solution is to simply render empty bins as zeros rather than transparent. This is what matplotlib does. The distinction between 0 and 1 should be usually negligible, having to do with noise and sample size.
Alternately, the default colormap for 2d histograms should have white at 0 (I don't think there's currently any such colormap, though some are close), or the default background for it should be black.
