# Plotting a distribution of planes

**URL:** <https://discourse.julialang.org/t/plotting-a-distribution-of-planes/53689>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [January 20, 2021, 10:19pm UTC](https://discourse.julialang.org/t/plotting-a-distribution-of-planes/53689 "2021-01-20T22:19:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlainz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainz/32/21183_2.png) [@mlainz](https://discourse.julialang.org/u/mlainz)\
**Post date:** [January 20, 2021, 10:19pm UTC](https://discourse.julialang.org/t/plotting-a-distribution-of-planes/53689/1 "2021-01-20T22:19:51Z")

</div>

A distribution of planes is an map that assigns a plane to each point of space. For example:  
 ![](https://global.discourse-cdn.com/julialang/original/3X/4/4/447d550ba15a6777e6d1e9272da683e3f973b052.png)  
A distribution can be defined by giving a field of normal vectors to the planes (more precisely, a one-form). In the case above, the normal vectors are [y,0,1].

How would you create a function for plotting distributions in Julia? Which package would you use?

---

<div class="post-metadata">

**Author:** ![mforets](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mforets/32/298_2.png) [@mforets](https://discourse.julialang.org/u/mforets)\
**Post date:** [January 21, 2021, 2:37pm UTC](https://discourse.julialang.org/t/plotting-a-distribution-of-planes/53689/2 "2021-01-21T14:37:46Z")

</div>

Hi @mlainz,

Here is a possible approach to construct the array. The packages that I loaded are [LazySets.jl](https://github.com/JuliaReach/LazySets.jl), [Polyhedra.jl](https://github.com/JuliaPolyhedra/Polyhedra.jl) and [Makie.jl](https://github.com/JuliaPlots/Makie.jl).

```julia
using LazySets, Makie, Polyhedra
using LazySets: HalfSpace, Hyperplane, translate # fix namespace conflicts

# x and y ranges
yrange = range(-2, 2, step=0.4)
xrange = copy(yrange)

# distribution of planes
planes = [Hyperplane([y, 0, 1], 0.0) for y in yrange];

# intersect with bounding box
box = BallInf(zeros(3), 0.1)
patches = [intersection(p, box) for p in planes];

# translate along x and y directions
vec = [translate(p, [x, -y, 0]) for x in xrange for (p, y) in zip(patches, yrange)];

```

Result:

```julia
# plot the array (FIXME: plot3d(vec), etc.)
plot3d(vec[1]); [plot3d!(vec[i]) for i in 2:length(vec)-1]; plot3d!(vec[end])

```

 ![Screenshot from 2021-01-21 11-32-35](https://global.discourse-cdn.com/julialang/original/3X/b/e/beba33524a1de2a58f15f15e762c5986f6e2fd01.png)

---

<div class="post-metadata">

**Author:** ![mlainz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainz/32/21183_2.png) [@mlainz](https://discourse.julialang.org/u/mlainz)\
**Post date:** [January 21, 2021, 3:33pm UTC](https://discourse.julialang.org/t/plotting-a-distribution-of-planes/53689/3 "2021-01-21T15:33:56Z")

</div>

Thank you!  
I will try to create a Plot recipe with that code.
