GUI
Info
Sometimes we already have data in Julia and just want to see the results without exporting it to other software for visualization, which is too troublesome...😢
We assume that your device has at least one modern browser that supports WebGL 2.0
Or you are using the official Julia extension in VSCode
This implementation is achieved through WGLMakie.jl, where users only need to provide the coordinates of the particles, and all other aspects are optional.
MaterialPointVisualizer.vispts Method
vispts(coord::Matrix; colorby::String, attr::Vector, psize::Real, colormap::Symbol=:turbo, sample_n::Int=1000000)
Description:
Visualize the particles in a browser/VSCode using WGLMakie.
coord: The coordinates of the particles. It should be a 2D or 3D array of shape (n, m), where m is the number of particles and n is the dimension (2 or 3).
colorby: The attribute name to plot with the particles.
attr: The attributes of the particles. It should be a vector of length m.
psize: The size of the particles in the visualization.
colormap [optional]: The colormap to use for the visualization. Default is :turbo.
sample_n [optional]: The number of particles to sample for visualization. Default is 1,000,000. If the number of particles exceeds this value, a random sample will be taken.
Examples:
vispts(rand(3, 10), colorby="attr's name", attr=rand(10), psize=3f0)
vispts(rand(2, 10), colorby="random vals", attr=rand(10), psize=1f0, sample_n=5, colormap=:jet)
MaterialPointVisualizer.visvol Method
visvol(coord::Matrix; colorby::String, attr::Vector, vsize::Real, colormap::Symbol=:turbo, sample_n::Int=1000000, ncolors::Int=64)
Description:
Visualize the particles in a 3D voxel grid using WGLMakie.
coord: The coordinates of the particles. It should be a 2D or 3D array of shape (n, m), where m is the number of particles and n is the dimension (2 or 3).
colorby: The attribute name to plot with the particles.
attr: The attributes of the particles. It should be a vector of length m.
vsize: The size of the voxels in the visualization.
colormap [optional]: The colormap to use for the visualization. Default is :turbo.
sample_n [optional]: The number of particles to sample for visualization. Default is 1,000,000. If the number of particles exceeds this value, a random sample will be taken.
ncolors [optional]: The number of colors in the colormap. Default is 64.
Examples:
function torus_points(n)
R, r, θ, ϕ = 1.0, 0.3, 2π * rand(n), 2π * rand(n)
x = (R .+ r .* cos.(θ)) .* cos.(ϕ)
y = (R .+ r .* cos.(θ)) .* sin.(ϕ)
z = r .* sin.(θ)
return Array(hcat(x, y, z)')
end
points = torus_points(1_000_000)
points[3, :] .+= 100
values = points[3, :] # z as the value to color by
visvol(points, colorby="torus", attr=values, vsize=0.01)
Warning
If you are connecting to a remote headless server via SSH, you may encounter issues.