Colored surface in Makie

I’m trying to draw transparent surfaces in Makie to illustrate separation boundaries between clusters. However, I can’t seem to get the surface function to respect the color argument. It seems to use the default colormap to map the z-values instead. This illustrates what I’m trying to do.

using AbstractPlotting, GLMakie

fig = Figure(resolution=(300,300))
lscene = LScene(fig[1,1], scenekw = (camera=cam3d!, raw=false))
x = range(-1.0, stop=1.0, length=100)
y = range(-1.0, stop=1.0, length=100)
f(x,y) = (r = x*x + y*y; exp(-r*r/2))
surface!(lscene, x, y, f, color=(:red, 0.5), shading=false, transparency=true)
fig

testfig

1 Like

for this kind of situation I use highclip = :red, or lowclip = :red, and set the colorrange with lower values to those.

1 Like

Cool, that works. It seems like there is a bug, though, since the color argument should override the colormap argument if set, no?

color argument should override the colormap argument if set, no?

I don’t know :D, probably it should.

for other users, this should work.

using GLMakie

fig = Figure(resolution=(500,500))
lscene = LScene(fig[1,1], scenekw = (camera=cam3d!, raw=false))
x = range(-1.0, stop=1.0, length=100)
y = range(-1.0, stop=1.0, length=100)
f(x,y) = (r = x*x + y*y; exp(-r*r/2))
surface!(lscene, x, y, f, colorrange = (-1,0), highclip=(:red, 0.8), shading=false, transparency=true)
fig

The following syntax can be used:

GLMakie.surface!(lscene, x, y, f, color=fill((:red,0.5),100,100), shading=false, transparency=true)

There is more control using Colors with RGBA:

using Colors
GLMakie.surface!(lscene, x, y, f, color=fill(RGBA(1.,0.,0.,0.5),100,100), shading=false, transparency=true)

3 Likes

Thanks! That is perhaps a more elegant solution. I can’t get it t work in WGLMakie, though (it works in GLMakie). Has anybody tried that?

I filed an issue with WGLMakie here

1 Like