3D plotting packages

I think you’re looking for something like this:

If you can rotate it, you’ll see the dark side… :slight_smile:


Yeah, somewhat like this. :smiley:

I can’t see any color. just grid. Thanks for the comment.
Your comment can be a hint. :slightly_smiling_face:

Can you please share a MWE? Also make sure you are using a recent release.

what is the MWE? I’ll try with a recent release.

There you can find the meaning of MWE.

This works for me:

using Meshes
using MeshViz
using Colors

# load a Makie backend
import GLMakie as Mke

grid  = CartesianGrid(10, 10, 10)
color = [RGB(i,j,k) for i in 0:0.1:0.9, j in 0:0.1:0.9, k in 0:0.1:0.9]
viz(grid, color=vec(color)) # need to flatten colors

1 Like

You need to flatten the vector of colors currently (we will fix that) and the vector must have the same length of the number of grid cells.

1 Like

I did the smae code. and I get this one. :laughing:
mixed order. but yes, this is what I was looking for. Vectorize is the key point!

Are you sure you are using the exact same code and latest release? That output is very unlikely :slight_smile:

1 Like

Oh, If I can rotate it, it would be amazing.
Also I like to see the inside of box. or slice it.

Yes, if you are using the GLMakie backend, you can rotate it.

For slices, you can create a meshdata object (see Meshes.jl docs) and then slice it.

Alternatively, you can take a look at Makie’s volumeslices:


1 Like

Sorry, I didn’t notice that you changed 1.0 to 0.9. :sweat_smile:

Now I have it.

1 Like

How’s this one:

using Plots
plotly() # for interactivity
x = [(i, j, k) for i in 0:0.1:1 for j in 0:0.1:1 for k in 0:0.1:1]; # [(0,0,0), (0,0,0.1), ... (0, 0.1, 0), (0, 0.1, 0.1), ... (1, 1, 1)]
plot(x; st=:scatter, color=[RGB(a...) for a in x], xguide="R", yguide="G", zguide="B", label=nothing)



Another way, using Colors and PlotlyJS:

using Colors, PlotlyJS

# meshbox by @milesfrain, https://github.com/JuliaPlots/Plots.jl/issues/1500
mesh_box(l,w,h,x,y,z, c) = PlotlyJS.mesh3d(
    x = [x, x+l, x, x+l, x, x+l, x, x+l],
    y = [y, y, y+w, y+w, y, y, y+w, y+w],
    z = [z, z, z, z, z+h, z+h, z+h, z+h],
    i = [0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7],
    j = [3, 3, 5, 5, 6, 6, 3, 3, 5, 5, 6, 6],
    k = [1, 2, 1, 4, 2, 4, 1, 2, 1, 4, 2, 4],
    color = c, flatshading = true

Δl = 0.1
boxes = GenericTrace{Dict{Symbol, Any}}[]
for k in 0:Δl:1, j in 0:Δl:1, i in 0:Δl:1
	push!(boxes, mesh_box(Δl,Δl,Δl,i,j,k, RGB(i,j,k)))

layout = Layout(scene = attr(xaxis_title="RED", yaxis_title="GREEN", zaxis_title="BLUE"))

PlotlyJS.plot(boxes, layout)

I have not converted this one yet to GMT.jl but if you want to fold and put the cube on your desk.


I didn’t know that Plots can do this ! So interesting! :smile:

Looks so professional! I want to fold that!

A solution in pure Makie:

using GLMakie

data = ((i, j, k, RGBf(i, j, k)) for i in 0:0.1:1,
                                     j in 0:0.1:1,
                                     k in 0:0.1:1)

x, y, z, color = (vec(getindex.(data, i)) for i in 1:4)

meshscatter(x, y, z; color)

and to show each color with a cube:

meshscatter(x, y, z; color, marker=Rect3((0,0,0), (1,1,1)))

1 Like

@rafael.guerra, that is awesome. Is it possible to have only the vertices of the boxes displayed as small circles (no boxes in)? I looked at the plotly documentation, but I am missing something. Thanks.