Last active
November 19, 2019 10:52
-
-
Save danscr/539f0840594b628335f7ebcc5ac19609 to your computer and use it in GitHub Desktop.
MWE of voxel plot using PGFPlotsX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using PGFPlotsX | |
#array with color mixture ratio | |
lam = rand(4,5,8) | |
# filter out values with less than 10% | |
s = sum(lam .> 0.1) | |
#rearrange to get each array position and color in vector format | |
xyz = Array{Float64}(undef,s,3) | |
col = Array{Float64}(undef,s) | |
let | |
l = 1 | |
for i in 1:4 | |
for j in 1:5 | |
for k in 1:8 | |
if Λ[i,j,k] > 0.1 | |
xyz[l,1] = i | |
xyz[l,2] = j | |
xyz[l,3] = k | |
col[l] = lam[i,j,k] | |
l += 1 | |
end | |
end | |
end | |
end | |
end | |
#scale position vectors | |
xyz *= 0.1 | |
p = @pgf Axis({ | |
view=(95,5), | |
"axis equal" | |
}, | |
(Plot3({only_marks, | |
mark="cube*", | |
mark_size="1mm", | |
fill="black!$(Int(floor(col[i]*100)))!red"}, | |
Table( | |
x=xyz[i,1], | |
y=xyz[i,2], | |
z=xyz[i,3])) for i in 1:s)...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment