# Plots -- transparency of surface?

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…)?

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.

alpha=0.5?

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…

… it is when I use surface plot with scatter plot that the result is somewhat poor.

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

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

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

1 Like

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

``````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)
``````
2 Likes

Great! I’ll test it tomorrow!

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:

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

which looks fine.

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

2 Likes

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

2 Likes