# How does the \`camera\` attribute of \`plot\` work?

**URL:** https://discourse.julialang.org/t/how-does-the-camera-attribute-of-plot-work/22139
**Category:** Visualization
**Tags:** plots
**Created:** [March 21, 2019, 12:37pm UTC](https://discourse.julialang.org/t/how-does-the-camera-attribute-of-plot-work/22139 "2019-03-21T12:37:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![adityam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adityam/32/7272_2.png) [@adityam](https://discourse.julialang.org/u/adityam)
#### Post date: [March 21, 2019, 12:37pm UTC](https://discourse.julialang.org/t/how-does-the-camera-attribute-of-plot-work/22139/1 "2019-03-21T12:37:49Z")

</div>

I am trying to understand how the camera attribute of plots works? The [documentation](https://docs.juliaplots.org/latest/attributes/) says

> Sets the view angle (azimuthal, elevation) for 3D plots

but I fail to visualize how I can set the view angle by specifying two numbers (rather than specifying the location of the camera and the angle at which it points).

My specific use case is to visualize the trajectories of replicator dynamics, which like on the 3D simplex. I want to view the plot from a camera angle so that the 3D simplex appears like a triangle but cannot figure out which coordinates to use for the camera attribute.

Here is the code:

```julia
juia> using DifferentialEquations, Plots

julia> pyplot()

julia> V(x,A,t) = x .* ( A*x .- x'*A*x)
V (generic function with 1 method)

julia> RPS = [0 -1. 1; 1 0 -1; -1 1 0]
3×3 Array{Float64,2}:
  0.0 -1.0 1.0
  1.0 0.0 -1.0
 -1.0 1.0 0.0

julia> tspan = (0,50.)
(0, 50.0)

julia> prob = ODEProblem(V,x0,tspan,RPS)
ODEProblem with uType Array{Float64,1} and tType Float64. In-place: false
timespan: (0.0, 50.0)
u0: [0.2, 0.2, 0.6]

julia> sol = solve(prob);

julia> plot(sol, vars=(1,2,3))

julia> plot(sol, vars=(1,2,3), camera=(1,1)))

```

---

<div class="post-metadata">

### Author: ![yashi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yashi/32/19448_2.png) [@yashi](https://discourse.julialang.org/u/yashi)
#### Post date: [May 4, 2022, 9:13am UTC](https://discourse.julialang.org/t/how-does-the-camera-attribute-of-plot-work/22139/2 "2022-05-04T09:13:42Z")

</div>

The `camera` attribute takes two real numbers, azimuthal and elevation. These values corresponds to Azimuth and Altitude in the following diagram.

![](https://global.discourse-cdn.com/julialang/original/3X/f/5/f5dce8b02ef6ffdc7246c08fe281c3fcaebb99ac.png)

These values are more like latitude and longitude and can take 0° to 360°, or -180° to +180°; But GR back-end seems to restrict the value from 0° to 90°.

Here is a working code for Julia 1.7 with the following packages and the outputs:

- Plots v1.28.1
- PyPlot v2.10.0

```julia
using DifferentialEquations
using Plots
using PyPlot

V(x,A,t) = x .* ( A*x .- x'*A*x)
RPS = [0 -1. 1; 1 0 -1; -1 1 0]
tspan = (0, 50.0)
x0 = [0.2, 0.2, 0.6]
prob = ODEProblem(V, x0, tspan, RPS)
sol = solve(prob);

gr()
anim = Animation()
for i in range(0, stop = 90, step = 1)
    p = Plots.plot(sol, vars=(1, 2, 3), camera=(i, i))
    frame(anim, p)
end
gif(anim, "gr.gif", fps=24)

pyplot()
anim = Animation()
for i in range(0, stop = 90, step = 1)
    p = Plots.plot(sol, vars=(1, 2, 3), camera=(i, i*2))
    frame(anim, p)
end
gif(anim, "pyplot.gif", fps=24)

```

![gr](https://global.discourse-cdn.com/julialang/original/3X/0/1/01998b70af0e8ffa31fe6a9019bc1e7f2f1399f4.gif)  
 ![pyplot](https://global.discourse-cdn.com/julialang/original/3X/9/6/9628ff5b05da8a47f531e55650cd00b5ba8b295c.gif)
