Show empty bins with 2d Gadfly histogram?

Can’t find it anywhere in the docs, so I guess this isn’t possible with hex or square bins?

Yes empty bins are hidden by default, and currently there’s no Geom.histogram2d argument to switch that. A workaround is to use a background Geom.rect:

using RDatasets
geyser = dataset("datasets","faithful")
plot(geyser, x=:Eruptions, y=:Waiting, Scale.color_continuous(minvalue=0),
  Geom.histogram2d(xbincount=30, ybincount=30),
  layer(xmin=[1.6], xmax=[5.2], ymin=[43], ymax=[96], Geom.rect, 
    color=[colorant"midnightblue"])
)

geyser

2 Likes