# Transparent surfaces in Makie.jl

**URL:** <https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 2, 2018, 7:00am UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775 "2018-10-02T07:00:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [October 2, 2018, 7:00am UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775/1 "2018-10-02T07:00:59Z")

</div>

I just got to know `Makie.jl` and I am enjoying its consistency. I am trying to plot points on the sphere, where the sphere should be a little transparent, since the points on the opposite side should be a little visible. My approach  
MWE reads as

```julia
using Makie
using Colors
using GeometryTypes
n = 33
u = range(0,stop=2*π,length=n);
v = range(0,stop=π,length=n);

x = zeros(n,n); y = zeros(n,n); z = zeros(n,n)
for i in 1:n
    for j in 1:n
        x[i,j] = cos.(u[i]) * sin(v[j]);
        y[i,j] = sin.(u[i]) * sin(v[j]);
        z[i,j] = cos(v[j]);
    end
end

scene = surface( x,y,z, show_axis=false, alpha=0.8,
  color = fill(RGBA(1.,1.,1.,0.8),n,n),
  limits=HyperRectangle(Vec(-1.01,-1.01,-1.01),Vec(1.01,1.01,1.01)) )
wireframe!( scene,x,y,z, show_axis=false,
  linewidth=1.2,color=RGBA(0.0,0.0,0.2,0.8) )
scatter!( scene,
  Point3f0.([[1.,0.,0.], 1/sqrt(2)*[1.,1.,0], 1/sqrt(3)*[1.,1.,1.], [-1.,0.,0.], [0.,0.,1.] ]),
  color=:blue, markersize=0.05, show_axis=false )

```

and produces.

 ![plot](https://global.discourse-cdn.com/julialang/original/3X/6/7/670002f23a9332b777b7006045c787e3923db259.png)  
I tried both `alpha=` and an `RGBA` for the surface, but somehow the white sphere is not transparent. How can I get the surface transparent?

Further in Jupyter this code produces both an (rendered) image (basically the one above), and a window that is interactive (Julia-Window). Is there an embedded interactive way for Jupyter? And can I deactivate one of the two outputs?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 3, 2018, 10:01am UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775/2 "2018-10-03T10:01:18Z")

</div>

This is currently an oddity from a trade off for transparency rendering…  
You need to put transparency at least to 0.4 to actually take effect ☹

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/6/f68890710aaf41fc737a243473528afd167dd21b.jpeg)

```plaintext
using Makie
using Colors
using GeometryTypes
n = 33
u = range(0,stop=2*π,length=n);
v = range(0,stop=π,length=n);
x = zeros(n,n); y = zeros(n,n); z = zeros(n,n)
for i in 1:n
    for j in 1:n
        x[i,j] = cos.(u[i]) * sin(v[j]);
        y[i,j] = sin.(u[i]) * sin(v[j]);
        z[i,j] = cos(v[j]);
    end
end

scene = surface(
  x,y,z,
  show_axis = false,
  color = fill(RGBA(1.,1.,1.,0.4), n, n),
  limits = HyperRectangle(Vec3f0(-1.01), Vec3f0(1.01))
)
wireframe!(
  scene, x, y, z,
  show_axis = false,
  linewidth = 1.2, color = RGBA(0.0,0.0,0.2,0.4))
scatter!(
  scene,
  Point3f0[
    (1.,0.,0.), 1/sqrt(2) .* (1.,1.,0), 1/sqrt(3) .* (1.,1.,1.), (-1.,0.,0.), (0.,0.,1.)
  ],
  color = :blue, markersize = 0.05, show_axis = false
)

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 3, 2018, 10:02am UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775/3 "2018-10-03T10:02:53Z")

</div>

> [@kellertuer](#):
>
> And can I deactivate one of the two outputs?

I put that on the final release todo list 🙂  
[https://github.com/JuliaPlots/Makie.jl/issues/134](https://github.com/JuliaPlots/Makie.jl/issues/134)

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [October 3, 2018, 12:45pm UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775/4 "2018-10-03T12:45:24Z")

</div>

Thanks, that was not mentioned anywhere, so I tried a few “old” approaches like the alpha. I like the RGBA more, though,  
And thanks for such a nice approach, having tried a few others, Makie seems the oe fitting my needs best for now.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [October 3, 2018, 12:46pm UTC](https://discourse.julialang.org/t/transparent-surfaces-in-makie-jl/15775/5 "2018-10-03T12:46:10Z")

</div>

…and if an interactive HTML-one for Jupyter would be available/possbile, that would be just perfect 🙂
