Makie stacked bar chart legends & labels inside axis

  1. How to place legend for stacked bar chart inside an axis. This can save lot of space on plots.
  2. How to place labels when drawing stacked bar chart

Sample code can be found in makie examples here

using CairoMakie

tbl = (x = [1, 1, 1, 2, 2, 2, 3, 3, 3],
       height = 0.1:0.1:0.9,
       grp = [1, 2, 3, 1, 2, 3, 1, 2, 3],
       grp1 = [1, 2, 2, 1, 1, 2, 1, 1, 2],
       grp2 = [1, 1, 2, 1, 2, 1, 1, 2, 1]
       )
barplot(tbl.x, tbl.height,
        stack = tbl.grp,
        color = tbl.grp,
        axis = (xticks = (1:3, ["left", "middle", "right"]),
                title = "Stacked bars"),
        )

Found the way to update legends inside

    CM.axislegend(ax1, 
        [PolyElement(polycolor = colors[i]) for i in [1,2]], 
        ["one","two"], "", 
        position = :lt, orientation = :horizontal)