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