Is x-axis linking ignored in Algebra of Graphics?

I want to plot a density for different groups that might have very different domains in AoG. My understanding is that in the following the x axes should be independent

dd = DataFrame(x = [rand(10)..., 10 .+ rand(10)...], c = [repeat('a', 10)..., repeat('b', 10)...])
data(dd) * 
mapping(:x, col = :c) * 
density() |> plt -> draw(plt, facet = (;linkxaxes = :none))

However I get the following

Am I misunderstanding something or is there a bug?

Just to be sure

julia> combine(groupby(dd, :c), :x => extrema)
2Γ—2 DataFrame
 Row β”‚ c     x_extrema             
     β”‚ Char  Tuple…                
─────┼─────────────────────────────
   1 β”‚ a     (0.0424785, 0.978699)
   2 β”‚ b     (10.0141, 10.9546)

The axes are technically not linked (for example, in an interactive setting, zooming on one will not zoom on the other), but by default density is evaluated on an interval that spans the whole dataset. You can change that by doing

data(dd) * 
mapping(:x, col = :c) * 
density(datalimits=extrema) |> plt -> draw(plt, facet = (;linkxaxes = :none))

In general, datalimits can take any function of the data (data comes in, tuple of values goes out), and it will be computed group by group.

1 Like

Thanks that makes sense!