# Volumetric plot?

**URL:** <https://discourse.julialang.org/t/volumetric-plot/119942>\
**Category:** New to Julia\
**Tags:** 3d, glmakie\
**Created:** [September 27, 2024, 9:10am UTC](https://discourse.julialang.org/t/volumetric-plot/119942 "2024-09-27T09:10:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![loisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loisel/32/50626_2.png) [@loisel](https://discourse.julialang.org/u/loisel)\
**Post date:** [September 27, 2024, 9:10am UTC](https://discourse.julialang.org/t/volumetric-plot/119942/1 "2024-09-27T09:10:05Z")

</div>

Hi,

I am considering putting some simple volumetric plots in my package. A previous MATLAB version of this project had simple volumetric plots based on Gouraud-shaded 3d triangular meshes with transparency. However, I don’t think that matplotlib (which is what I currently use) supports those.

Is there a no-nonsense package for volumetric plots?

This is all happening in jupyter lab on a Mac, if that matters. I think I may have asked the same question here years ago, but the packages I tried then ended up not working.

Thanks!

S

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [September 27, 2024, 9:49am UTC](https://discourse.julialang.org/t/volumetric-plot/119942/2 "2024-09-27T09:49:02Z")

</div>

Something like this is in GridVisualize.jl (I am the author).

```julia
using ExtendableGrids,GridVisualize,GLMakie
X=-1:0.05:1
g=simplexgrid(X,X,X)
f=map((x,y,z)->exp(-2(x^2+y^2+z^2)),g)
scalarplot(g,f,Plotter=GLMakie)

```

 ![t](https://global.discourse-cdn.com/julialang/original/3X/0/5/05355f4d2b17e958c7d1a85721d4ee922bd88afd.png)

---

<div class="post-metadata">

**Author:** ![loisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loisel/32/50626_2.png) [@loisel](https://discourse.julialang.org/u/loisel)\
**Post date:** [September 27, 2024, 9:52am UTC](https://discourse.julialang.org/t/volumetric-plot/119942/3 "2024-09-27T09:52:40Z")

</div>

I’ll give it a shot. I have “unstructured meshes” of tetrahedra (not a 3d tensor on a regular grid), is that supported?

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [September 27, 2024, 11:44am UTC](https://discourse.julialang.org/t/volumetric-plot/119942/4 "2024-09-27T11:44:27Z")

</div>

Yes, this is supported. In fact this is all what is supported, the simplexgrid call creates a tetmesh.

Look for an appropriate constructor in

> **[Grid constructors · ExtendableGrids.jl](https://j-fu.github.io/ExtendableGrids.jl/stable/gridconstructors/#ExtendableGrids.simplexgrid)**
>
> Documentation for ExtendableGrids.jl.

I may add some more if there is some need.

---

<div class="post-metadata">

**Author:** ![loisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loisel/32/50626_2.png) [@loisel](https://discourse.julialang.org/u/loisel)\
**Post date:** [September 27, 2024, 11:21pm UTC](https://discourse.julialang.org/t/volumetric-plot/119942/5 "2024-09-27T23:21:35Z")

</div>

Thanks for this.

I was reading the documentation you linked. I’m not sure I understand all the parameters of your constructor. I can probably come up with some sort of `coord` and `cellnodes` but what’s the other three parameters?

S

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [September 28, 2024, 7:48am UTC](https://discourse.julialang.org/t/volumetric-plot/119942/6 "2024-09-28T07:48:33Z")

</div>

These are the connectivity for a boundary (codim1) subgrid,  
and material markers for cells and boundaries. This comes  
from the context of boundary value problems for PDEs.

What should work immediately is the following:

- cellregions=ones(Int, size(cellnodes,2))
- bfacenodes: just one triangle of your first cell
- bfaceregions=ones(Int, size(bfacenodes,2))

Also, if your coordinates are stored as points, you probably can convert them to the matrix using reinterpret, as to avoid to copy the data.

That said, I have plans to streamline this to an API which works just with coords, tets and values, and possibly also with meshes from GeometryBase etc. but never took the time to get through with this.

I may have another look at this in the next couple of days.

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [September 29, 2024, 1:27pm UTC](https://discourse.julialang.org/t/volumetric-plot/119942/7 "2024-09-29T13:27:20Z")

</div>

Just registering the new version 1.8. This will allow to do e.g.

```julia
scalarplot(coord, cellnodes, funcvalues; Plotter=GLMakie

```
