# Magnifier lens of various shapes in Plots or Makie

**URL:** <https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [May 4, 2021, 9:25pm UTC](https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547 "2021-05-04T21:25:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 4, 2021, 9:25pm UTC](https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547/1 "2021-05-04T21:25:06Z")

</div>

I came across the two gif animations in the following slides in a talk that I attended last year (they are not moving 🤣 in the pictures that I attached).

I wonder if I can reproduce the same animations, in particular, the _ **circular / elliptical magnifier lens with Plots or Makie** _.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/8/78e5b3192082ce1a2c101ba7af2b89e2190edf16.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/8/e8011097061fe864509a87ff0fb026ee007adcca.png)

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [May 4, 2021, 9:48pm UTC](https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547/2 "2021-05-04T21:48:44Z")

</div>

In Plots I would use `lens` with borders turned off and draw an ellipse on top with `Shape`. You may even manage to draw the ellipse in the original plot and have it zoom with the lens. This won’t be perfect, but it might work.

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 4, 2021, 10:05pm UTC](https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547/3 "2021-05-04T22:05:07Z")

</div>

I found `lens` in the documentation of `Plots`. I will try to tweak around with the provided example tomorrow. At the moment it seems that any attributes I pass to `inset` will also apply to the main plot.  
[https://docs.juliaplots.org/latest/generated/gr/#gr-ref40](https://docs.juliaplots.org/latest/generated/gr/#gr-ref40)

Drawing ellipse and lines is not too difficult, the main problem is probably to be to turn off the right things.

---

<div class="post-metadata">

**Author:** ![Wei\_Yang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wei_yang/32/23951_2.png) [@Wei\_Yang](https://discourse.julialang.org/u/Wei_Yang)\
**Post date:** [May 19, 2021, 11:40pm UTC](https://discourse.julialang.org/t/magnifier-lens-of-various-shapes-in-plots-or-makie/60547/4 "2021-05-19T23:40:15Z")

</div>

Here is a working example

```julia
using Plots, LinearAlgebra

circle1 = 0.5.+0.1.*cis.(0:0.01:2pi)
circle2 = 2.0+2.0im.+cis.(0:0.01:2pi)

id(z) = norm(z-0.5) <=0.1 
ani = @animate for n = 2:10:400
    E = randn(n,n)/sqrt(n)|>eigvals
    E|>x->scatter(x,xlims=(-2,3),ylims=(-2,3),ratio=1,leg=false,ms=2)
    (10*(E[id.(E)].-(0.5+0im)).+(2+2.0im))|>scatter!
    plot!(circle1,fill=true,alpha=0.3,c=:green)
    plot!(circle1,lw=2,c=:orange)
    plot!(circle2,fill=true,alpha=0.1,c=:green)
    plot!(circle2,lw=2,c=:orange)
    plot!([0.5,1],[0.1,2],c=:orange,lw=2)
    plot!([0.6,2],[0,1],c=:orange,lw=2)
    title!("Local Circular Law")
end
gif(ani,"ani.gif")

```

![ani](https://global.discourse-cdn.com/julialang/original/3X/5/a/5a770d7e5b359945e079c3774f728e0ca4bb35b1.gif)
