# Makie coloring of surface plots

**URL:** <https://discourse.julialang.org/t/makie-coloring-of-surface-plots/15298>\
**Category:** Visualization\
**Created:** [September 21, 2018, 5:33pm UTC](https://discourse.julialang.org/t/makie-coloring-of-surface-plots/15298 "2018-09-21T17:33:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lwhitefox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lwhitefox/32/4363_2.png) [@lwhitefox](https://discourse.julialang.org/u/lwhitefox)\
**Post date:** [September 21, 2018, 5:33pm UTC](https://discourse.julialang.org/t/makie-coloring-of-surface-plots/15298/1 "2018-09-21T17:33:59Z")

</div>

My understanding is that when generating surface plots in Makie, colors are assigned per vertex. I’m surprised that when I run the small sample code below, which assigns one color value for each vertex in a 4 by 3 set of points, the color seems to be assigned midway between points. Specifically, in the screen grab showing the displayed plot, the red values show at x=0.5 instead of x=0.0.  
Questions:

- is this expected?
- is there a way to have colors applied at the desired points?

To run the sample code, I am using the Julia 1.0 REPL, and when the code is in a file mweColor.jl, I type `include(mweColor.jl)`.

Code (output image follows):

```julia
using Makie 

x1vals=collect(-1.0:1:2)
x2vals=collect(-1.0:1:1)

xPlotGrid = [x1vals[ix] for ix in 1:length(x1vals), iy in 1:length(x2vals)]
yPlotGrid = [x2vals[iy] for ix in 1:length(x1vals), iy in 1:length(x2vals)]
zPlotGrid = [0.0 for ix in 1:length(x1vals), iy in 1:length(x2vals)]

myColArray = [ if i==2
               :red
               else
               :green
               end for i in 1:length(x1vals), j in 1:length(x2vals)]

scene = Scene()
surface!(scene,xPlotGrid, yPlotGrid, zPlotGrid, color=myColArray)

# sanity check of color assignment:
for i in 1:length(x1vals)
    println(myColArray[i,:])
end

return(scene)

```

Image:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/4/a4822424b886ddf0197eb621efd207b499c5d6f9.jpeg)

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 21, 2018, 10:45pm UTC](https://discourse.julialang.org/t/makie-coloring-of-surface-plots/15298/2 "2018-09-21T22:45:24Z")

</div>

Looks like a bug 😉

---

<div class="post-metadata">

**Author:** ![lwhitefox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lwhitefox/32/4363_2.png) [@lwhitefox](https://discourse.julialang.org/u/lwhitefox)\
**Post date:** [September 22, 2018, 2:30pm UTC](https://discourse.julialang.org/t/makie-coloring-of-surface-plots/15298/3 "2018-09-22T14:30:16Z")

</div>

Hmmmm, I will not try to argue with you! 🤔

I’ve tried to look into the internals of Makie in the src directory without success; I cannot find where the vertex info is set up (it doesn’t help either that my limited experience with OpenGL was some years ago…)
