# How to plot two surfaces by Makie.jl

**URL:** <https://discourse.julialang.org/t/how-to-plot-two-surfaces-by-makie-jl/126750>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [March 10, 2025, 8:51am UTC](https://discourse.julialang.org/t/how-to-plot-two-surfaces-by-makie-jl/126750 "2025-03-10T08:51:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee123](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@Lee123](https://discourse.julialang.org/u/Lee123)\
**Post date:** [March 10, 2025, 8:51am UTC](https://discourse.julialang.org/t/how-to-plot-two-surfaces-by-makie-jl/126750/1 "2025-03-10T08:51:54Z")

</div>

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

```julia
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

 ![截屏2025-03-10 16.27.32](https://global.discourse-cdn.com/julialang/original/3X/b/5/b59edb9ec5d52ce8982cae270e31daa13b2ae5a2.png)  
the first surface is covered by the second surface like a 2D plot, but the two surfaces should have intersection as follow (by mathematica)  
 ![截屏2025-03-10 16.50.13](https://global.discourse-cdn.com/julialang/original/3X/b/6/b6256c3c85ccc89621cec415a001f8b984f3d18f.png)  
how to realized above figure by Makie? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [March 10, 2025, 9:35am UTC](https://discourse.julialang.org/t/how-to-plot-two-surfaces-by-makie-jl/126750/2 "2025-03-10T09:35:40Z")

</div>

just do `transparency=true`.

```Julia
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](https://beautiful.makie.org/dev/examples/3d/surfaces/surface).

---

<div class="post-metadata">

**Author:** ![Lee123](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@Lee123](https://discourse.julialang.org/u/Lee123)\
**Post date:** [March 10, 2025, 10:52am UTC](https://discourse.julialang.org/t/how-to-plot-two-surfaces-by-makie-jl/126750/4 "2025-03-10T10:52:02Z")

</div>

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