AlgebraOfGraphics is essentially a way to do some preprocessing before sending data to Makie for the plot. In your case, you end up calling heatmap
with the following signature:
heatmap(diamonds.cut::Vector, diamonds.color::Vector, color::Vector=diamonds.Price)
but heatmap(x, y, color=z)
is not supported in Makie. Beyond that, there is no way to guess that you actually want the mean price given the x
and y
variable. Taking the mean value can be handled by AoG with reducer
. For example, here is the 1D case:
using AlgebraOfGraphics, CairoMakie, RDatasets
using AlgebraOfGraphics: reducer
diamonds = dataset("ggplot2", "diamonds")
p = data(diamonds) *
mapping(:Cut => categorical, :Price) *
reducer() *
visual(BarPlot)
draw(p)
I was imagining that the following
diamonds = dataset("ggplot2", "diamonds")
p = data(diamonds) *
mapping(:Cut => categorical, :Color => categorical, :Price) *
reducer() *
visual(Heatmap)
draw(p)
would just work, but unfortunately it looks like heatmap(x::Vector, y::Vector, z::Vector)
is not supported out of the box in Makie. I can check over at Makie if it makes sense to add it there, otherwise the small reshape necessary (from the โlongโ to the โmatrixโ format) can be handled in AoG.
UPDATE: the syntax
diamonds = dataset("ggplot2", "diamonds")
p = data(diamonds) * mapping(:Cut => categorical, :Color => categorical, :Price) * reducer
draw(p)
now works on AlgebraOfGraphics master branch.