# Makie: Isosurface colored by values from another array

**URL:** <https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318>\
**Category:** Visualization\
**Tags:** makie, meshes\
**Created:** [October 23, 2023, 3:32pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318 "2023-10-23T15:32:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 23, 2023, 3:32pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/1 "2023-10-23T15:32:50Z")

</div>

I have two 3D arrays. I would like to make an isosurface from the first one and color it using the values of the second array. As far as I understand, a possible solution would be to construct a mesh for the isosurface (e.g. by marching cubes) and then, using interpolation, calculate the values of the second array at the mesh vertices.

So far I found [Makie: Colouring 3D Contours by another Array](https://discourse.julialang.org/t/makie-colouring-3d-contours-by-another-array/88829/) discussion from where I adopted the following code:

```julia
import GLMakie as mak
import Interpolations: linear_interpolation
import MarchingCubes: MC, march
import Meshes
import MeshViz

function mesh_data(vals, isovalue)
    mc = MC(vals, Int)
    march(mc, isovalue)
    return mc
end

xmin, xmax, Nx = -10, 10, 101
ymin, ymax, Ny = -10, 10, 101
zmin, zmax, Nz = -10, 10, 101

x = range(xmin, xmax, Nx)
y = range(ymin, ymax, Ny)
z = range(zmin, zmax, Nz)

G = [zi <= 0 || sqrt(xi^2+yi^2+zi^2) <= 5 ? 1.0 : 0.0 for xi=x, yi=y, zi=z]

F = [cos(sqrt(xi^2+zi^2)) for xi=x, yi=y, zi=z]

# Extract an isosurface of G at isovalue=1
meshes = mesh_data(G, 1)
mesh_points = Meshes.Point3[pt for pt=meshes.vertices]
mesh_tris = Meshes.connect.([Tuple(tri) for tri in meshes.triangles], Meshes.Triangle)
to_SimpleMesh = Meshes.SimpleMesh(mesh_points, mesh_tris)

# Interpolate F to colour by onto the vertex locations
# Marching cubes uses cell indices starting at 0
itp = linear_interpolation((0:Nx-1, 0:Ny-1, 0:Nz-1), F)
F_at_verts = [itp(pt[1], pt[2], pt[3]) for pt=Meshes.coordinates.(to_SimpleMesh.vertices)]

fig = mak.Figure()
ax = mak.Axis3(fig[1,1]; aspect=:data)
mak.plot!(ax, to_SimpleMesh; color=F_at_verts)

mak.display(fig)

```

which gives the following:

 ![out](https://global.discourse-cdn.com/julialang/original/3X/a/7/a72e5c2b25848a845362957bd802c5bc0e09b81f.png)

However, this solution uses a deprecated package `MeshViz` and I do not understand how I can change the properties of the final plot.

Another related examples are:

1. [Visualizing a 3D volume in Makie: Lighting, smoothness](https://discourse.julialang.org/t/visualizing-a-3d-volume-in-makie-lighting-smoothness/35263/7)
2. [ANN: Meshing 0.5.0](https://discourse.julialang.org/t/ann-meshing-0-5-0/29034/2)

However, these examples do not work because Makie does not want to plot the meshes generated there.

Do you know how to realize this isosurface coloring using Makie and currently maintained packages?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 23, 2023, 3:43pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/2 "2023-10-23T15:43:06Z")

</div>

Didn’t have the time to read the details of the code, but please take a look at our recent book, chapters 2, 10 and 11:

[https://juliaearth.github.io/geospatial-data-science-with-julia](https://juliaearth.github.io/geospatial-data-science-with-julia)

You can interpolate fields over arbitrary meshes with the `Interpolate` and `InterpolateNeighbors` transforms.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 23, 2023, 3:55pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/3 "2023-10-23T15:55:41Z")

</div>

Thank you for the link. The book seems to be interesting. However, I can not find there any examples on how to take a 3D array and construct a mesh for its isosurface. I hope, the interpolation is the easiest step here.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 23, 2023, 3:58pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/4 "2023-10-23T15:58:39Z")

</div>

After you construct the isosurface mesh with any method of interest, you can simply call the `viz` plot recipe on it. The MeshViz.jl package was converted into a package extension, which is available whenever you load Meshes.jl and Makie.jl in the same session.

The book explains how you can visualize different fields over the mesh (geometry column).

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 23, 2023, 5:31pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/5 "2023-10-23T17:31:35Z")

</div>

Oh, thank you. MeshViz.jl held the older version of Meshes.jl. When I removed it, the `viz` function became available.  
The updated version of the code:

```julia
import GLMakie
import Interpolations
import MarchingCubes
import Meshes

function mesh_data(x, y, z, vals; isovalue=1)
    mc = MarchingCubes.MC(vals, Int; x, y, z)
    MarchingCubes.march(mc, isovalue)
    return mc
end

# Prepare data:
x = collect(range(-10, 10, 101))
y = collect(range(-10, 10, 101))
z = collect(range(-10, 10, 101))
G = [zi <= 0 || sqrt(xi^2+yi^2+zi^2) <= 5 ? 1.0 : 0.0 for xi=x, yi=y, zi=z]
F = [cos(sqrt(xi^2+zi^2)) for xi=x, yi=y, zi=z]

# Extract the isosurface of G at isovalue=1:
mc = mesh_data(x, y, z, G; isovalue=1)
mesh_points = [Meshes.Point3(vt) for vt=mc.vertices]
mesh_triangles = Meshes.connect.([Tuple(tri) for tri=mc.triangles], Meshes.Triangle)
simple_mesh = Meshes.SimpleMesh(mesh_points, mesh_triangles)

# Interpolate F at vertex locations:
itp = Interpolations.linear_interpolation((x, y, z), F)
Fcolors = [itp(pt[1], pt[2], pt[3]) for pt=Meshes.coordinates.(simple_mesh.vertices)]

# Visualize:
fig = GLMakie.Figure()
ax = GLMakie.Axis3(fig[1,1]; aspect=:data)
Meshes.viz!(ax, simple_mesh; color=Fcolors)
GLMakie.display(fig)

```

and the output:

 ![out](https://global.discourse-cdn.com/julialang/original/3X/4/0/40b88b55a7af811d3c2c663f81dfeaa57213e8bb.png)

However, I would prefer the original Makie visualization functions. Do you know what kind of mesh object I have to provide to `Makie.mesh` function in order to make it work? Do you know where I can find the sources of `viz` function? In Meshes.jl I found only its [template](https://github.com/JuliaGeometry/Meshes.jl/blob/cb8f3dfd5514df6c89aacb00911b8dbe4c0b255a/src/viz.jl).

And slightly unrelated questions. Do you know any good resource where I can find how to control the light sources in Makie? There are not so much information in the documentation.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 23, 2023, 5:40pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/6 "2023-10-23T17:40:20Z")

</div>

The viz recipe is defined in Meshes/ext for different mesh types using dispatch. If you want to keep things at a high level I would stick to it and follow the recommendations in the book. Feel free to go low level and use Makie.jl directly with points and connec lists of triangles.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [October 23, 2023, 10:11pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/7 "2023-10-23T22:11:34Z")

</div>

A volume plot like `volume(x, y, z, G, isovalue = 1.0)` should give you the same shape but it doesn’t allow you to paint `F` on the surface. (I think that’s what’s happening here?) This also includes lighting. I’d guess your examples don’t because they don’t generate normals or because the normals face the other direction.

With this specific example you could also reorganize your data to have `z(x, y)` and `F(x, y)` and plot it as a `surface(x, y, z_xy, color = F_xy)`. If that’s not an option you’ll have to generate a mesh like in your examples.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 7:41am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/8 "2023-10-24T07:41:12Z")

</div>

Yes, the main issue is to paint the surface using an external array.

I managed to find out how to control the lights by `set_theme!` function:

```julia
GLMakie.set_theme!(
    lightposition = GLMakie.Vec3f(1,1,1),
    ambient = GLMakie.RGBf(1,1,1),
    # backlight = 1,
    # shininess = 128f0,
    # specular = GLMakie.RGBf(1,1,0),
    # diffuse = GLMakie.RGBf(1,0,1),
)

```

(though it seems that the commented parameters do nothing).

 ![out](https://global.discourse-cdn.com/julialang/original/3X/e/6/e6ec5626c4d20560b5244dd07d28f438302e6dd1.png)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 24, 2023, 9:21am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/9 "2023-10-24T09:21:16Z")

</div>

If `ambient` is `1` then there’s maximum light everywhere already. If `backlight` is on, the other parameters should become visible no matter the normal orientation.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [October 24, 2023, 9:49am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/10 "2023-10-24T09:49:07Z")

</div>

`backlight` might get ignored by the backend if it’s not a Float32. It wasn’t set up with a conversion originally and I’m not sure if that ever got fixed

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 9:56am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/11 "2023-10-24T09:56:11Z")

</div>

Yes, I do not see any the effects of other parameters even if I set `ambient = GLMakie.RGBf(0.5,0.5,0.5)` and `backlight = true`.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 10:01am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/12 "2023-10-24T10:01:33Z")

</div>

@jules, @ffreyer maybe you know how to prepare a proper mesh for `Makie.mesh` function. The use of `Meshes.viz` is very unconvinient. For example, I can not change the `colorrange` attribute no matter what I do. Or I can not change the `colormap` through `set_theme!`; it seems `Meshes.viz` redefines it.

---

<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:** [October 24, 2023, 10:06am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/13 "2023-10-24T10:06:42Z")

</div>

Does this help?  
[https://docs.makie.org/stable/reference/plots/mesh/#using\_geometrybasicsmesh\_and\_buffersampler\_type](https://docs.makie.org/stable/reference/plots/mesh/#using_geometrybasicsmesh_and_buffersampler_type)  
Btw, we found out that the lighting isn’t all that correct at the moment and @ffreyer has been fixing it here

> <https://github.com/MakieOrg/Makie.jl/pull/3246>
>
> \# Description
> 
> This is currently an experimental pr looking to improve lightin…g.
> 
> \## Change Summary
> 
> This pr adds/changes:
> \- (breaking) \`backlight\` now affects \`normal\` instead of \`lightdir\`. This means specular reflections show up with backlight
> \- (breaking) changed default light direction (position), light intensities, diffuse and specular attributes 
> \- (minor breaking) change default light to \`DirectionalLight\` (closes #3239)
> \- (minor breaking) added smoothing of \`diff\_coeff\` around 0. This softens the edge where normals are perpendicular to the light direction)
> \- (non-breaking change) \`shading\` attribute is now \`:none/:fast/:verbose\` instead of true or false
> \- (internal/maybe breaking) moved scaling in Axis3 from view to model matrix and stopped connecting scenes/plots with different spaces. The latter is something I want to do for #3013.
> \- (new) support for multiple light sources (need not be unique, ref #1592)
> \- (new) \`PointLight\` now has attenuation parameters (distance based intensity falloff, off by default)
> \- (new) added \`DirectionalLight\` (parallel light rays)
> \- (new) added \`SpotLight\` (light source illuminating a cone)
> \- (fix) the light color of \`PointLight\` (and all others) is now connected (fixes #3238)
> \- (internal) \`colorbuffer()\` now polls events to trigger \`render\_tick\` so that it can cause lighting updates
> \- (internal) light calculation moved to world space which shouldn't change anything visually
> \- (internal) loosen type restriction on \`lights\` vector (fix #2985)
> 
> 
> \## Type of change
> 
> \- \[x\] breaking (backlight, default light, smoothing around 0 intensity)
> 
> \## TODO
> 
> \- \[x\] Hook up updates (for individual lights and the lights array)
> \- \[x\] implement more simple light types (SpotLight, DirectionalLight, PointLight with attentuation)
> \- \[x\] Hook up \`shading\`
> \- \[x\] Update other backends to work with changes made to the lighting interface
> \- \[x\] Implement new lights in RPRMakie
> \- \[x\] lighting in volume 
> \- \[x\] backlight
> \- \[x\] record updates
> \- \[x\] Added an entry in NEWS.md (for new features and breaking changes)
> \- \[x\] Added or changed relevant sections in the documentation
> \- \[x\] Added unit tests for new algorithms, conversion methods, etc.
> \- \[x\] Added reference image tests for new plotting functions, recipes, visual options, etc.
> \- \[x\] check/fix missing normals for matcap with NoShading
> \- \[x\] fix WGLMakie
> \- \[x\] fix laggy directional light in WGLMakie (move camera-space light direction calculation to javascript)
> \- \[x\] fix Axis3
> \- \[x\] fix images in docs (MultiLightShading and SSAO fail to render correctly)

If you want to give that a try, I think it also contains some better docs:  
[https://docs.makie.org/previews/PR3246/reference/scene/lighting/](https://docs.makie.org/previews/PR3246/reference/scene/lighting/)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 24, 2023, 10:19am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/14 "2023-10-24T10:19:42Z")

</div>

@fedoroff take a look at the docstring of the `viz` function. It explains the options and rationale. If some keyword argument is missing that should be forwarded to the Makie.jl internal call, feel free to suggest the addition.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 10:32am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/15 "2023-10-24T10:32:47Z")

</div>

> [@sdanisch](#):
>
> Does this help?  
> [mesh · Makie](https://docs.makie.org/stable/reference/plots/mesh/#using_geometrybasicsmesh_and_buffersampler_type)

Not really. Unfortunately, now I do not have enough knowledge to understand what is going on there. I will try to read more on how `GeometryBasics` define meshes. Thank you.

> [@sdanisch](#):
>
> Btw, we found out that the lighting isn’t all that correct at the moment and @ffreyer has been fixing it here

The examples there look really amazing. I hope we will see it soon in the production.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 10:45am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/16 "2023-10-24T10:45:28Z")

</div>

> [@juliohm](#):
>
> @fedoroff take a look at the docstring of the `viz` function. It explains the options and rationale. If some keyword argument is missing that should be forwarded to the Makie.jl internal call, feel free to suggest the addition.

The docstring of `viz` is very bref. For example, I want to change the `colorrange` attribute to enhance the colors. The docstring does not mention this argument. If I write something like  
`Meshes.viz!(ax, simple_mesh; color=Fcolors, colorscheme, colorrange=(0,0.1))`, nothing happens. Does it mean that the `Meshes` owners have to manually add every keyword argument which is available in the original Makie function?

And, sorry, but I still can not find the exact place in `Meshes` sources where `viz` is defined. I searched through the sources using “viz” keyword and found nothing. Can you, please, give me a direct link where I can see what is the internal machinery of `viz`?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 24, 2023, 10:52am UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/17 "2023-10-24T10:52:30Z")

</div>

> [@fedoroff](#):
>
> The docstring of `viz` is very bref. For example, I want to change the `colorrange` attribute to enhance the colors. The docstring does not mention this argument. If I write something like  
> `Meshes.viz!(ax, simple_mesh; color=Fcolors, colorscheme, colorrange=(0,0.1))`, nothing happens.

The color range is set automatically based on the `extrema(colors)`. This is what most users would expect in practice, specially when they are using the `viewer` function that adjusts the color bar accordingly when a different variable is selected from the menu. Can you please clarify what you mean by enhacing the colors?

> [@fedoroff](#):
>
> Does it mean that the `Meshes` owners have to manually add every keyword argument which is available in the original Makie function?

The `viz` recipe is a high-level utility function that simply forwards all defined options to Makie.jl internal functions. The current list of options was defined based on real needs from users, and we can certainly brainstorm more options if a new use case shows up. It is not clear to me yet what do you mean by “enhance colors”.

> [@fedoroff](#):
>
> And, sorry, but I still can not find the exact place in `Meshes` sources where `viz` is defined. I searched through the sources using “viz” keyword and found nothing. Can you, please, give me a direct link where I can see what is the internal machinery of `viz`?

> <https://github.com/JuliaGeometry/Meshes.jl/tree/master/ext>
>
> //github.com/JuliaGeometry/Meshes.jl/tree/master/ext

The `ext` folder contains all the `viz` methods as I explained above. The specific method you are looking for `SimpleMesh` is written in simplemesh.jl

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 12:00pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/18 "2023-10-24T12:00:26Z")

</div>

> [@juliohm](#):
>
> Can you please clarify what you mean by enhacing the colors?

When the data has a very large dynamic range (a lot of details at small values) or it is corrupted by, for example, some “broken pixels”, then, like in the example below, by changing the `colorrange` we can visualize some specific details which are not visible with the default color scale. In other words, we can oversaturate the colors to force some tiny details to be visible.

```julia
import GLMakie as mak

x = range(-10, 10, 101)
y = range(-10, 10, 101)
F = [0.1*exp(-(xi^2+yi^2)/4^2) + 1e-4*sin((xi^2+yi^2)/2^2) for xi=x, yi=y]
F[25,25] = 1 # broken pixel

fig = mak.Figure(resolution=(1500,600))

ax1 = mak.Axis(fig[1,1]; title="Default colorrange")
hm1 = mak.heatmap!(ax1, x, y, F)
mak.Colorbar(fig[2,1], hm1; vertical=false, flipaxis=false)

ax2 = mak.Axis(fig[1,2]; title="colorrange=(0,0.1)")
hm2 = mak.heatmap!(ax2, x, y, F; colorrange=(0,0.1))
mak.Colorbar(fig[2,2], hm2; vertical=false, flipaxis=false)

ax3 = mak.Axis(fig[1,3]; title="colorrange=(0,0.001)")
hm3 = mak.heatmap!(ax3, x, y, F; colorrange=(0,0.001))
mak.Colorbar(fig[2,3], hm3; vertical=false, flipaxis=false)

mak.display(fig)

```

 ![out](https://global.discourse-cdn.com/julialang/original/3X/6/a/6a2cbe6a15f37b429f85d63b60a8fb645702baeb.png)

> [@juliohm](#):
>
> The `ext` folder contains all the `viz` methods as I explained above. The specific method you are looking for `SimpleMesh` is written in simplemesh.jl

In the file simplemesh.jl I see only the following functions:  
`Makie.plottype(::SimpleMesh) = Viz{<:Tuple{SimpleMesh}}`  
`function Makie.plot!(plot::Viz{<:Tuple{SimpleMesh}})`  
`function vizmesh1D!(plot)`  
`function vizmesh2D!(plot)`  
`function vizmesh3D!(plot)`  
`function segmentsof(topo, vert)`  
`function segmentsof(topo::GridTopology, vert)`

I would expect that when I call `Meshes.viz` function, there is somewhere an entry point defined as `function viz(some_arguments)`. And I can not find it. What does exactly happens when I call `Meshes.viz`?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [October 24, 2023, 12:23pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/19 "2023-10-24T12:23:15Z")

</div>

> [@fedoroff](#):
>
> When the data has a very large dynamic range (a lot of details at small values) or it is corrupted by, for example, some “broken pixels”, then, like in the example below, by changing the `colorrange` we can visualize some specific details which are not visible with the default color scale. In other words, we can oversaturate the colors to force some tiny details to be visible.

Perhaps that could be achieved with a different scale other than the linear scale? Sometimes log scale can address some of these visualization issues. We could also say that the issue is in the data, and that you should preprocess it first before sending to `viz`. Check the `DropExtrema`, `Scale` and similar transforms in chapter 5:

[https://juliaearth.github.io/geospatial-data-science-with-julia/05-transforms.html](https://juliaearth.github.io/geospatial-data-science-with-julia/05-transforms.html)

> [@fedoroff](#):
>
> I would expect that when I call `Meshes.viz` function, there is somewhere an entry point defined as `function viz(some_arguments)`. And I can not find it. What does exactly happens when I call `Meshes.viz`?

This is the Makie.jl recipe system. The keyword arguments are defined in the plot object. If you read the code you will find lines accessing `plot[:colorscheme]` for example.

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [October 24, 2023, 1:24pm UTC](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318/20 "2023-10-24T13:24:34Z")

</div>

> [@juliohm](#):
>
> Perhaps that could be achieved with a different scale other than the linear scale? Sometimes log scale can address some of these visualization issues. We could also say that the issue is in the data, and that you should preprocess it first before sending to `viz`. Check the `DropExtrema`, `Scale` and similar transforms in chapter 5:

I believe that the data is primary and thus I would prefer not to preprocess it (besides, in some cases it can take sufficient amount of time), but instead use already existing tools for its visualization. That is why I would like to use Makie directly and not rely on third-part wrappers that cut the functionality of the original functions. I assume that `viz` covers all your needs. However, I need a little bit more.

> [@juliohm](#):
>
> This is the Makie.jl recipe system. The keyword arguments are defined in the plot object. If you read the code you will find lines accessing `plot[:colorscheme]` for example.

Unfortunately, I am not familiar with the recipe system. It looks for me like some black magic. There is a function which you can call, but its body is defined nowhere. I have to read more about it.

[Next page](https://discourse.julialang.org/t/makie-isosurface-colored-by-values-from-another-array/105318.md?page=2)
