Once you want to add other objects, it makes more sense to use a Figure
(which is just a parent Scene
with a layout basically) and place an LScene
in there (that’s a Scene
which can be placed in a layout) and then you can place a Colorbar
next to that:
using Makie.Distributions
x = rand(Dirichlet([5,1,1,5]), 100)
f = Figure()
s = LScene(f[1, 1], show_axis = false)
p1 = Point3f(sqrt(8/9), 0, -1/3)
p2 = Point3f(-sqrt(2/9), sqrt(2/3), -1/3)
p3 = Point3f(-sqrt(2/9), -sqrt(2/3), -1/3)
p4 = Point3f(0, 0, 1.0)
frame = linesegments!(
s,
[
(p1, p2),
(p1, p3),
(p1, p4),
(p2, p3),
(p2, p4),
(p3, p4),
],
color = :black,
)
text!(s, [p1, p2, p3, p4] .* 1.2, text = ["P1", "P2", "P3", "P4"], align = (:center, :center))
function to_quaternary(v1, v2, v3, v4, p1, p2, p3, p4)
v1 * p1 + v2 * p2 + v3 * p3 + v4 * p4
end
scat = scatter!(s,
[to_quaternary(c[1], c[2], c[3], c[4], p1, p2, p3, p4) for c in eachcol(x)],
color = 1:size(x, 2),
)
zoom!(s.scene, 0.7)
Colorbar(f[1, 2], scat)
f