# Statically rotate 3D scene in Makie.jl

**URL:** <https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356>\
**Category:** General Usage\
**Tags:** makie, 3d\
**Created:** [January 10, 2022, 7:53pm UTC](https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356 "2022-01-10T19:53:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattwigway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattwigway/32/22520_2.png) [@mattwigway](https://discourse.julialang.org/u/mattwigway)\
**Post date:** [January 10, 2022, 7:53pm UTC](https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356/1 "2022-01-10T19:53:07Z")

</div>

I am plotting a bivariate normal distribution in Makie. After generating the values, I plot it with this code (full MWE below):

```julia
fig = Figure()
ax1 = Axis3(fig[1,1], xlabel="Selection error term", ylabel="Outcome error term")
s = surface!(ax1, XY, XY, grid)

```

where XY is a vector with x and y values defining a regular grid the same shape as `grid`. I get this nice-looking scene:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/8/3885e86c110127cd5c8562baae545a0dd22d09d2.png)

I want to rotate the scene so that I am looking at it with negative X to the left and ahead, and positive Y to the right and ahead, so 90 degrees to the right of where the camera is now. I can do this in the GLMakie window by dragging, and it looks like I want it to, but I need to be able to do it programatically. I’ve tried a number of different ways (listed below), but I can’t get the camera to a position where the Z axis doesn’t look too flat (somehow I seem to be clobbering the Z exaggeration when I move the camera), and the axis ticks are on the side of the figure towards the camera.

Full MWE:

```julia
using GLMakie, Distributions
const XY = collect(range(-3, 3, length=100))
const ρ = 0.7
dist = MvNormal([0, 0], [1 ρ; ρ 1])

grid = zeros(Float64, (100, 100))

for (x, i) in enumerate(XY)
    for (y, j) in enumerate(XY)
        grid[x, y] = pdf(dist, [i, j])
    end
end
  
fig = Figure()
ax1 = Axis3(fig[1,1], xlabel="Selection error term", ylabel="Outcome error term")
surface!(ax1, XY, XY, grid)

```

Things I’ve tried (all at the end after the `surface!` call):

Seems to only rotate the camera to point in the wrong direction, also flattens the scene. I’ve tried putting the 90 in each position, and also tried with \pi in case it’s expecting radians.

```julia
cam3d!(ax1.scene)
rotate_cam!(ax1.scene, 0, 90, 0)

```

Not sure what this does. I thought it would move the camera to (5, -5, 1) looking at (0, 0, 0) but I can’t figure out what it actually did:

```julia
    cam3d!(ax1.scene)
    update_cam!(ax1.scene, [0, 0, 0], [5, -5, 1])

```

---

<div class="post-metadata">

**Author:** ![mattwigway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattwigway/32/22520_2.png) [@mattwigway](https://discourse.julialang.org/u/mattwigway)\
**Post date:** [January 10, 2022, 7:56pm UTC](https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356/2 "2022-01-10T19:56:12Z")

</div>

Images of the last two examples:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/5/e5e8f57c8434b63731dc661dd198fc122a89e039.jpeg)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/e/9e6de6ef9ca3c1784f22e897d269f398cf923aae.png)

---

<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:** [January 10, 2022, 8:55pm UTC](https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356/3 "2022-01-10T20:55:39Z")

</div>

Axis3 has the attributes azimuth and elevation, which control the angles you’re interested in. Increase azimuth by pi/2 I guess?

---

<div class="post-metadata">

**Author:** ![mattwigway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattwigway/32/22520_2.png) [@mattwigway](https://discourse.julialang.org/u/mattwigway)\
**Post date:** [January 11, 2022, 2:17pm UTC](https://discourse.julialang.org/t/statically-rotate-3d-scene-in-makie-jl/74356/4 "2022-01-11T14:17:05Z")

</div>

That works, thanks!
