Makie.jl
Makie.jl copied to clipboard
volume plot of negative values fails
A volume plot with negative values does not seem to work.
Consider the following example (adapted from Beautiful Makie):
using GLMakie # same with WGLMakie
let
x = y = z = 1:10
f(x, y, z) = x^2 + y^2 + z^2
vol = [-f(ix, iy, iz) for ix in x, iy in y, iz in z]
fig, ax, _ = volume(vol; colorrange = (minimum(vol), maximum(vol)), transparency = true,
figure = (; resolution = (1200, 800)), axis = (; type = Axis3))
display(fig)
end
I get a single-colored volume plot:
It works for positive values:
using GLMakie # same with WGLMakie
let
x = y = z = 1:10
f(x, y, z) = x^2 + y^2 + z^2
vol = [f(ix, iy, iz) for ix in x, iy in y, iz in z] # removed the `-` here
fig, ax, _ = volume(vol; colorrange = (minimum(vol), maximum(vol)), transparency = true,
figure = (; resolution = (1200, 800)), axis = (; type = Axis3))
display(fig)
end
GLMakie v0.5.5
Interestingly, this issue seems to be fixed by normalizing the data manually to the 0 .. 1 range instead of using the colorrange argument:
using GLMakie
let
x = y = z = range(1.0,10.0,length=11)
f(x, y, z) = x^2 + y^2 + z^2
vol = [-f(ix, iy, iz) for ix in x, iy in y, iz in z]
vol .-= minimum(vol)
vol ./= maximum(vol)
fig, ax, _ = volume(vol; transparency = true, figure = (; resolution = (1200, 800)), axis = (; type = Axis3))
display(fig)
end
Note: I had to replace the coordinate ranges by floating point values to make the in-place normalization work.