Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent surface plots #126

Closed
dpsanders opened this issue Jun 29, 2017 · 4 comments
Closed

Transparent surface plots #126

dpsanders opened this issue Jun 29, 2017 · 4 comments

Comments

@dpsanders
Copy link

dpsanders commented Jun 29, 2017

The alpha parameter seems to have no effect for surface plots.

e.g. this example from the NLSolve.jl README:

f(x, y) = ((x+3)*(y^3-7)+18, sin(y*exp(x)-1))

surface(-5:0.05:5, -5:0.05:5, (x,y)->f(x,y)[1], alpha=0.5, zlim=(-2, 2))
surface!(-5:0.05:5, -5:0.05:5, (x,y)->f(x,y)[2], alpha=0.5)

(which shows that there is a continuum of solutions, by the way).

@sglyon
Copy link
Member

sglyon commented Jun 29, 2017

Yeah, in this case you are looking for opacity, not alpha.

See docs here https://plot.ly/javascript/reference/#surface-opacity

@sglyon
Copy link
Member

sglyon commented Jun 29, 2017

Hmm, it looks like this isn't even valid code for PlotlyJS.jl

Are you using Plots.jl to create the surface?

Here's an example from this package's docs that has opacity in a surface:

function multiple_surface()
    z1 = Vector[[8.83, 8.89, 8.81, 8.87, 8.9, 8.87],
                [8.89, 8.94, 8.85, 8.94, 8.96, 8.92],
                [8.84, 8.9, 8.82, 8.92, 8.93, 8.91],
                [8.79, 8.85, 8.79, 8.9, 8.94, 8.92],
                [8.79, 8.88, 8.81, 8.9, 8.95, 8.92],
                [8.8, 8.82, 8.78, 8.91, 8.94, 8.92],
                [8.75, 8.78, 8.77, 8.91, 8.95, 8.92],
                [8.8, 8.8, 8.77, 8.91, 8.95, 8.94],
                [8.74, 8.81, 8.76, 8.93, 8.98, 8.99],
                [8.89, 8.99, 8.92, 9.1, 9.13, 9.11],
                [8.97, 8.97, 8.91, 9.09, 9.11, 9.11],
                [9.04, 9.08, 9.05, 9.25, 9.28, 9.27],
                [9, 9.01, 9, 9.2, 9.23, 9.2],
                [8.99, 8.99, 8.98, 9.18, 9.2, 9.19],
                [8.93, 8.97, 8.97, 9.18, 9.2, 9.18]]
    z2 = map(x->x+1, z1)
    z3 = map(x->x-1, z1)
    trace1 = surface(z=z1, colorscale="Viridis")
    trace2 = surface(z=z2, showscale=false, opacity=0.9, colorscale="Viridis")
    trace3 = surface(z=z3, showscale=false, opacity=0.9, colorscale="Viridis")
    plot([trace1, trace2, trace3])
end

@dpsanders
Copy link
Author

Ah yes, sorry, using Plots.jl.
Can Plots.jl just translate alpha to opacity?

@sglyon
Copy link
Member

sglyon commented Jun 30, 2017

It looks like alpha and opacity are synonyms in plots.jl: https://github.com/JuliaPlots/Plots.jl/blob/cadb0f96e2adc1fe749e46998bd78e8da7c133e9/src/args.jl#L412

But by doing a quick search over opacity in the plotly backend it doesn't appear to be used: https://github.com/JuliaPlots/Plots.jl/blob/master/src/backends/plotly.jl

I'll close here as it seems to be an issue over there. Should be easy enough for them to fix.

@sglyon sglyon closed this as completed Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants