# Plots -- transparency of surface?

**URL:** <https://discourse.julialang.org/t/plots-transparency-of-surface/24524>\
**Category:** Visualization\
**Tags:** pyplot, plots\
**Created:** [May 23, 2019, 2:55pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524 "2019-05-23T14:55:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 23, 2019, 2:55pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/1 "2019-05-23T14:55:32Z")

</div>

Can I control the transparency/alpha value of the surface in surface plots? I would like to superimpose the solution of an ode on a surface… `fillalpha=0.2` doesn’t have an effect. Another way to do it? (e.g. using wireframe and make that transparent…)?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 24, 2019, 6:44am UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/2 "2019-05-24T06:44:59Z")

</div>

OK… with `pyplot()` backend, it works to superimpose `:path3d` series type on a `:surface` (i.e., I see the lines with the default surface settings), but markers disappear/are hidden/are difficult to see.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [May 24, 2019, 1:05pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/3 "2019-05-24T13:05:35Z")

</div>

alpha=0.5?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 24, 2019, 1:15pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/4 "2019-05-24T13:15:55Z")

</div>

I tried `alpha=0.5` for surface plot. No error message, but similar result as before.

Note: the combination of surface plot and line3d plot works ok…

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/2/72bf4dc1c493621e068f448ec010e8c8ca2b63ac.jpeg)  
… it is when I use surface plot with scatter plot that the result is somewhat poor.

---

<div class="post-metadata">

**Author:** ![ccmejia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccmejia/32/18680_2.png) [@ccmejia](https://discourse.julialang.org/u/ccmejia)\
**Post date:** [September 28, 2021, 1:28am UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/5 "2021-09-28T01:28:40Z")

</div>

Hey! Did you find the solution?  
Behavior is the same for me.

```julia
N = 100
	
x = range(0, 1, length = N)
y = range(-1, 1, length = N)
z = range(-1, 1, length = N)
X = x' .* ones(N); Y = ones(N)' .* y
	

const_color = cgrad( [RGB{Float64}(0.9,0.9,0.9) for _ in 1:2] )
Z = 2pi*ones(N, N)
	
surface(Z, Y, X, xlims = (0, 4pi), xaxis=false, yaxis=false, zaxis=false, 
		xlabel = " ", ylabel = " ", zlabel = " ",
		framestyle = :false, minogrid = :false, colorbar = false, alpha = 0.5,
		color = const_color, ratio = 5.5)  

```

Does not show transparency…

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [September 28, 2021, 5:41pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/6 "2021-09-28T17:41:23Z")

</div>

Not really… But I haven’t looked at it again the last 2 years.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 28, 2021, 7:12pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/7 "2021-09-28T19:12:06Z")

</div>

Fyi, `surface` transparency seems to be working fine with the `pyplot()` backend:

 ![Plots_pyplot_surface_transparency](https://global.discourse-cdn.com/julialang/original/3X/4/2/42f3942af7778abdf58b9f64fbf06b34c0b2aa66.jpeg)

```julia
using Plots; pyplot()
N = 100
x = y = range(-1, 1, N)
X = x' .* ones(N)
Y = ones(N)' .* y
Z = sin.(X .* Y).^2

const_color = cgrad( [RGB{Float64}(0.9,0.3,0.5) for _ in 1:2] )
surface(X, Y, zero(Z) .- .5, alpha = 1)
surface!(X, Y, Z, xaxis=false, yaxis=false, zaxis=false, 
		xlabel = " ", ylabel = " ", zlabel = " ", color = const_color,
		framestyle = :false, minogrid = :false, colorbar = false, alpha = 0.5) 

```

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [September 28, 2021, 7:38pm UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/8 "2021-09-28T19:38:09Z")

</div>

Great! I’ll test it tomorrow!

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [September 29, 2021, 11:05am UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/9 "2021-09-29T11:05:35Z")

</div>

> [@rafael.guerra](#):
>
> `y = range(-1, 1, N)`

I had to change this line to `y = range(-1,1,length=N)` to make it work. Perhaps I have an outdated version of `Plots.jl`?

I modified the script slightly, into:

```julia
using Plots; pyplot()
N = 100
x = y = range(-1, 1, length=N)
X = x' .* ones(N)
Y = ones(N)' .* y
Z = exp.(-(X.*X + X.*Y + Y.*Y)/0.5)#sin.(X .* Y).^2

#const_color = cgrad( [RGB{Float64}(0.9,0.3,0.5) for _ in 1:2] )
#surface(X, Y, zero(Z) .- .5, alpha = 0.3)
surface(X, Y, Z, xaxis=false, yaxis=false, zaxis=false, 
		xlabel = " ", ylabel = " ", zlabel = " ", #color = const_color,
		framestyle = :false,minogrid = :false, colorbar = false, alpha = 0.7)
D1 = 0.3*rand(3,5)
X1 = D1[1,:]
Y1 = D1[2,:]
Z1 = D1[3,:]
scatter3d!(X1,Y1,Z1,label=" ")
scatter3d!(X1.+0.5,Y1.-0.5,Z1.+1,label=" ")

```

which gave the result:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/2/1218f024ed539af191951cfc4f8b4e891a871368.jpeg)  
which looks fine.

Don’t know exactly why the `zaxis` still is shown, though.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 29, 2021, 11:47am UTC](https://discourse.julialang.org/t/plots-transparency-of-surface/24524/10 "2021-09-29T11:47:15Z")

</div>

> [@BLI](#):
>
> Don’t know exactly why the `zaxis` still is shown, though.

Fyi, using argument `framestyle=:none` gets rid of it
