How to plot two surfaces by Makie.jl

I want to plot two surfaces in one figure, for example

using CairoMakie

x = range(-pi, pi, 128)
y = x'
z1 = broadcast((x,y)->cos(x)+cos(y), x,y)
z2 = -1.0.*z1
f,_,_ = surface(x,x,z1; axis=(type=Axis3,),colormap=:jet)
surface!(x,x,z2,colormap=:jet)
f

the result is


the first surface is covered by the second surface like a 2D plot, but the two surfaces should have intersection as follow (by mathematica)

how to realized above figure by Makie? Thanks in advance!

1 Like

just do transparency=true.

x = range(-pi, pi, 128)
y = x'
z1 = broadcast((x,y)->cos(x)+cos(y), x,y)
z2 = -1.0.*z1
f,_,_ = surface(x,x,z1; axis=(type=Axis3,),colormap=:jet, transparency=true)
surface!(x,x,z2,colormap=:jet, transparency=true)
f

also, you could add a wireframe, if needed as in here.

using GLMakie solve the problem, setting transparency=true can make it more beautiful, thx!