# How to embed 2D slices of an array in a 3D plot using plot recipes?

**URL:** <https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857>\
**Category:** Visualization\
**Tags:** plotting, recipe\
**Created:** [February 16, 2019, 11:57am UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857 "2019-02-16T11:57:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 16, 2019, 11:57am UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/1 "2019-02-16T11:57:53Z")

</div>

Given a 3D array, I would like to produce the following visualization:

 ![Screenshot%20from%202019-02-16%2009-37-57](https://global.discourse-cdn.com/julialang/original/3X/0/b/0ba9952d4b68876c2a845e4d49cd1342bbca1bf5.jpeg)

The main problem I have is that I don’t know how to embed 2D slices in a 3D plot using plot recipes. Appreciate if you can help, or if you can provide an alternative solution.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [February 16, 2019, 1:03pm UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/2 "2019-02-16T13:03:39Z")

</div>

You can follow this “tutorial” for Makie:

> **[fMRI Data Visualization with Julia in Minutes](https://nextjournal.com/ekinakyurek/fmri-visualization-with-julia)**

There is a bug in there right now, which I can try to fix today 😉  
I think it’s just that `colornorm` is wrong in heatmap, you can play around it yourself in this command:

```plaintext
heatmap!(
   hscene, axis2, axis2, volume[][indices...], colornorm = (0, 1)
)

```

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 16, 2019, 1:08pm UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/3 "2019-02-16T13:08:53Z")

</div>

Thank you @sdanisch, I am looking for a `RecipesBase.jl`, I should have been more specific, sorry. The visualization of the brain is awesome anyways!

Is it possible to write a recipe that consumes a 3D array and produces the slices as heatmaps?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [February 16, 2019, 2:18pm UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/4 "2019-02-16T14:18:44Z")

</div>

fair enough 😉 i was thinking to turn it into a makie recipe, but i guess thats also not what you want then 😉

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 16, 2019, 3:33pm UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/5 "2019-02-16T15:33:46Z")

</div>

A Makie recipe would be great as I plan to move Plots → Makie at some point in the future when things are more stable and working. 👍

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [February 18, 2019, 9:26am UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/6 "2019-02-18T09:26:40Z")

</div>

I’d use Makie for this. But AFAIK Makie doesn’t yet have a lightweight recipe format.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [February 18, 2019, 11:49am UTC](https://discourse.julialang.org/t/how-to-embed-2d-slices-of-an-array-in-a-3d-plot-using-plot-recipes/20857/7 "2019-02-18T11:49:02Z")

</div>

It would be nice to keep in mind these embeddings of lower dimensional objects in a higher-dimensional space while designing the new recipes system 👍
