# Colored surface in Makie

**URL:** https://discourse.julialang.org/t/colored-surface-in-makie/61009
**Category:** Visualization
**Tags:** makie
**Created:** [May 12, 2021, 9:46am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009 "2021-05-12T09:46:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [May 12, 2021, 9:46am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/1 "2021-05-12T09:46:15Z")

</div>

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.

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/9/5/95bf180fe63407d89667544d2e4e79f2c82595cc.png)

---

<div class="post-metadata">

### Author: ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)
#### Post date: [May 12, 2021, 9:56am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/2 "2021-05-12T09:56:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [May 12, 2021, 9:59am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/3 "2021-05-12T09:59:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)
#### Post date: [May 12, 2021, 10:03am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/4 "2021-05-12T10:03:07Z")

</div>

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

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

for other users, this should work.

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

```

 ![Screenshot 2021-05-12 at 12.01.00](https://global.discourse-cdn.com/julialang/original/3X/5/2/52655231f9e7c56e14aca8d55572f5594594dd7e.png)

---

<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: [May 12, 2021, 11:49am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/5 "2021-05-12T11:49:10Z")

</div>

The following syntax can be used:

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

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

```

 ![Makie_transparent_colored_surface](https://global.discourse-cdn.com/julialang/original/3X/d/2/d26fc34ea01ed96901935b5199b08476b25c4427.png)

---

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [May 16, 2021, 11:25pm UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/6 "2021-05-16T23:25:19Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)
#### Post date: [May 18, 2021, 2:38am UTC](https://discourse.julialang.org/t/colored-surface-in-makie/61009/7 "2021-05-18T02:38:00Z")

</div>

I filed an issue with WGLMakie [here](https://github.com/JuliaPlots/WGLMakie.jl/issues/100)
