Contour plot on Structured grid using Meshes.jl

If you use Contour.jl, things go down pretty smoothly (straight from the Contour.jl documentation) (the “import Contour as CT” avoids conflicts with other definitions of contour in Makie or other graphics packages)

#(...)

import Contour as CT

#(...)

psirange = (minimum(safe_log.(psi)), maximum(safe_log.(psi)))
for cl in CT.levels(CT.contours(x, z, safe_log.(psi), 10))
    lvl = CT.level(cl) # the z-value of this contour level
	@info "Level: $lvl"
    for line in CT.lines(cl)
        xs, ys = CT.coordinates(line) # coordinates of this line segment
        lines!(ax, xs, ys, color=lvl, colorrange=psirange, colormap=:jet) # pseudo-code; use whatever plotting package you prefer
    end
end
fig
1 Like