# Rotate a subplot in MakieLayout?

**URL:** <https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573>\
**Category:** Visualization\
**Created:** [October 18, 2020, 4:54am UTC](https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573 "2020-10-18T04:54:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [October 18, 2020, 4:54am UTC](https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573/1 "2020-10-18T04:54:29Z")

</div>

I am trying to make the individual cubes in the grid of graphs rotate below, but get: "ERROR: MethodError: no method matching transformation(::LAxis)

I am not sure how to refer to a specific axis or subscene’s mesh to rotate the graph. Code:

```
 using LinearAlgebra, Makie
using AbstractPlotting.MakieLayout
using AbstractPlotting

const N = 40
const interval = 0.07

const scene, layout = layoutscene(30, resolution = (1200, 900))

const axes = [LAxis(scene) for i in 1:4, j in 1:4]
tightlimits!.(axes)
layout[1:4, 1:4] = axes

for ax in axes
    mesh!(ax, FRect3D(Vec3f0(-0.5), Vec3f0(1)), color = :aquamarine)
end

display(scene)

for rad in 0.5:1/N:8.5, ax in axes
    arr = normalize([cospi(rad/2), 0, sinpi(rad/2), -sinpi(rad/2)])
    Makie.rotate!(ax, Quaternionf0(arr[1], arr[2], arr[3], arr[4]))
    sleep(interval)
end

const N = 40
const interval = 0.07

const scene, layout = layoutscene(30, resolution = (1200, 900))

const axes = [LAxis(scene) for i in 1:4, j in 1:4]
tightlimits!.(axes)
layout[1:4, 1:4] = axes

for ax in axes
    mesh!(ax, FRect3D(Vec3f0(-0.5), Vec3f0(1)), color = :skyblue2)
end

display(scene)

for rad in 0.5:1/N:8.5, ax in axes
    arr = normalize([cospi(rad/2), 0, sinpi(rad/2), -sinpi(rad/2)])
    Makie.rotate!(ax, Quaternionf0(arr[1], arr[2], arr[3], arr[4])) # if not 'ax' here, what?
    sleep(interval)
end

```

---

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [October 19, 2020, 6:49am UTC](https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573/2 "2020-10-19T06:49:27Z")

</div>

Ah, found it by trying a few things-- the line should be

```
Makie.rotate!(ax.scene, Quaternionf0(arr[1], arr[2], arr[3], arr[4])) 

```

because apparently each LAxis can contain a subscene field called scene.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 19, 2020, 6:58am UTC](https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573/3 "2020-10-19T06:58:33Z")

</div>

Be aware, though, that by manipulating the scene contained in LAxis like that, you break assumptions for the tick positions etc, basically behavior is undefined from that point

---

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [October 20, 2020, 6:46am UTC](https://discourse.julialang.org/t/rotate-a-subplot-in-makielayout/48573/4 "2020-10-20T06:46:01Z")

</div>

So if the ticks are wrong after a rotation, can I turn the axes of the plots off below?

```
using LinearAlgebra, Makie
using AbstractPlotting.MakieLayout
using AbstractPlotting

const N = 40
const interval = 0.05

const scene, layout = layoutscene(30, resolution = (1200, 900))

const axes = [LAxis(scene) for i in 1:4, j in 1:4]
tightlimits!.(axes)
layout[1:4, 1:4] = axes

for ax in axes
    mesh!(ax, FRect3D(Vec3f0(-0.6), Vec3f0(1.2)), color =:aquamarine, show_axis=false)
    xlims!(ax, [-1, 1])
    ylims!(ax, [-1, 1])
end

display(scene)

for rad in 0.5:1/N:8.5
    arr = normalize([cospi(rad/2), 0, sinpi(rad/2), -sinpi(rad/2)])
    chosen = rand(vec(axes), 4)
    for ax in chosen
        Makie.rotate!(ax.scene, Quaternionf0(arr[1], arr[2], arr[3], arr[4]))
    end
    sleep(interval)
end

```
