Contour plots on non-rectangular domain

As it happens, my use case does indeed exclusively involve mapped rectangular domains. I can use the Contour.jl package that you’re suggesting to make the basic contour plots work. However, getting filled contour plots to work (which is really the interesting case) still seems like a significant implementation effort. I’d be happy to hear of any packages that can help with that.

In case anyone is interested, here is a working example that can handle various transformations (mostly copied from the Contour.jl tutorial):

using Plots
using Contour
gr()

transformation(r,θ) = (@.r*cos(θ) ,@.r*sin(θ))

r = 1:0.01:2
θ = 0:0.01π:0.5π
f(r,θ) = cos((r-0.5)*3)+sin(θ)
p1 = Plots.contour(r,θ,f,nlev=20)

p2 = plot()
z = [f(ri,θi) for ri in r, θi in θ]
conts = contours(r,θ,z,20)
for cl in levels(conts)
    for line in lines(cl)
        xline,yline = transformation(coordinates(line)...)
        plot!(xline,yline, label="")
    end
end
plot(p1,p2,size=(500,250))

which produces:

image