Wind Rose 'hard' stacked barplot edges in GLMakie

There isn’t a simple way to get that yet. Somewhere between the barplot and the Polar transform applying, the Rect2f’s barplot generates need to get interpolated. You can hack Makie to do that like this:

tbl = (cat = [1, 1, 1, 2, 2, 2, 3, 3, 3],
       height = 0.1:0.1:0.9,
       grp1 = [1, 2, 2, 1, 1, 2, 1, 1, 2],
       grp2 = [1, 1, 2, 1, 2, 1, 1, 2, 1]
       );

f = Figure(width=200, height=200);

ax = PolarAxis(f[1, 1],
    rticks=1:0.1:1,
    );

p = barplot!(ax,
    tbl.cat, 
    tbl.height,
    stack = tbl.grp1,
    color = tbl.grp2,
    colormap=:lightrainbow,
);
pp = popat!(p.plots, findfirst(x -> x isa Poly, p.plots))
polys = map(pp.converted[1]) do rects
    map(rects) do rect
        N_steps = 100
        mini = minimum(rect); maxi = maximum(rect)
        ps = Point2f[mini, Point2f(mini[1], maxi[2]), maxi, Point2f(maxi[1], mini[2]), mini]
        ps = map(range(0, 4, length = N_steps)) do f
            ps[1] * max(0, 1-f) + 
            ps[2] * max(0, 1 - abs(f-1)) + 
            ps[3] * max(0, 1 - abs(f-2)) + 
            ps[4] * max(0, 1 - abs(f-3)) + 
            ps[5] * max(0, 1 - abs(f-4))
        end
        Makie.Polygon(ps)
    end
end
poly!(p, pp.attributes, polys)

f

This will fail if you display before the poly!() call. Also worth an issue I think

5 Likes