I would like to build a 3D contour plot, with the contours constructed based on a given array and the colours on said contours defined by a second array. An example relevant to me is the Inviscid Taylor-Green Vortex:
using GLMakie
function InitConds(x, y, z)
γ = 1.4; R = 287.15
vx = sin(x) * cos(y) * cos(z)
vy = -cos(x) * sin(y) * cos(z)
vz = 0
p = 1e5 + ((cos(2 * z) + 2) * (cos(2 * x) + cos(2 * y)) - 2) / 16
ρ = 1
T = p / (R * ρ)
return ρ * sqrt(vx^2 + vy^2 + vz^2), ρ * (log(T^(γ / (γ - 1))) / log(p))
end
domain_size = 2π
npts = 64; dx = domain_size / npts
points = LinRange(dx / 2, domain_size - dx / 2, npts)
data = [InitConds(x, y, z) for x = points, y = points, z = points]
KinEnergy = getindex.(data, 1)
Entropy = getindex.(data, 2)
fig = Figure()
ax = Axis3(fig[1, 1], title = "Inviscid Taylor Green Vortex")
contour!(ax, points, points, points, KinEnergy, levels = 5)
display(fig)
At the moment, this plots contours of KinEnergy, with the contours coloured by the value of KinEnergy. I would like the contours to be coloured by Entropy- is this possible? I haven’t been able to find an example in the Makie docs or in BeautifulMakie.
As an aside, is there a more elegant way to pull out values from broadcasted functions that return multiple values than what I did with KinEnergy and Entropy?