AlgebraOfGraphics.jl icon indicating copy to clipboard operation
AlgebraOfGraphics.jl copied to clipboard

Heatmap coloring boxes that should be empty

Open jariji opened this issue 3 years ago • 4 comments

I expected the ! facet m row to be empty but it has colored boxes without text. There is also something strange going on with the tick alignment around there.

let
  n = 1000
  df = DataFrame(x=rand('A':'Z',n), y=rand('a':'z',n), z=rand(1:1000,n), c=rand('!':'%',n))
  d = combine(groupby(df, [:x,:y,:c]), :z => sum)
  # Remove values for one facet and row.
  subset!(d, [:x,:y,:c,:z_sum] => ByRow((x,y,c,z)-> !((c == '!') && (y == 'm'))))
  ll = (
      data(d)
      * mapping(:x,:y; layout=:c)
      * (
          visual(Heatmap) * mapping(:z_sum)
          + visual(Makie.Text; align=(:center,:center), color=:red) * mapping(text=:z_sum=>verbatim∘string)
        )
  )
  draw(ll; figure=(;resolution=(3000,2000)))
end

image

[cbdf2221] AlgebraOfGraphics v0.6.8
[13f3f980] CairoMakie v0.8.6
[ee78f7c6] Makie v0.17.6
julia 1.7.1

jariji avatar Jun 25 '22 19:06 jariji

What's happening IMO is the following. Makie sees a gap in the axis (from l to n, which has been automatically translated to integers by AoG) and is expanding the boxes to fill in the gap. A simpler MWE would be

using CairoMakie
heatmap([1, 2, 4, 5], [1, 2, 3, 4], rand(4))

heatmap

The conversion is happening here. This should probably be fixed on the Makie side first. Maybe one could allow an optional width argument to heatmap to help compute correct edges?

piever avatar Jul 06 '22 08:07 piever