# How to plot circles with given radii using Plots

**URL:** <https://discourse.julialang.org/t/how-to-plot-circles-with-given-radii-using-plots/47845>\
**Category:** General Usage\
**Tags:** plots\
**Created:** [October 6, 2020, 9:54am UTC](https://discourse.julialang.org/t/how-to-plot-circles-with-given-radii-using-plots/47845 "2020-10-06T09:54:29Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![anowacki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anowacki/32/17375_2.png) [@anowacki](https://discourse.julialang.org/u/anowacki)\
**Post date:** [October 7, 2020, 11:19am UTC](https://discourse.julialang.org/t/how-to-plot-circles-with-given-radii-using-plots/47845/9 "2020-10-07T11:19:49Z")

</div>

It’s not clear just how fast this needs to be, or whether this solution would also class as ‘too slow’, but passing a `Vector{Plots.Shape}` seems acceptably fast for me with thousands of `Shape`s.

The following example will give you a load of randomly-wiggling circles.

```julia
using Plots

function circle(x, y, r=1; n=30)
    θ = 0:360÷n:360
    Plots.Shape(r*sind.(θ) .+ x, r*cosd.(θ) .+ y)
end

function move_circles!(circles; Δ=0.01)
    for c in circles
        dx = Δ*(2rand() - 1)
        dy = Δ*(2rand() - 1)
        c.x .+= dx
        c.y .+= dy
    end
    nothing
end

nframes = 100
ncircles = 1000

circles = circle.([i*rand(ncircles) for i in (1, 1, 0.01)]...)

plot_kwargs = (aspect_ratio=:equal, fontfamily="Helvetica", legend=false, line=nothing,
    color=:black, grid=false, xlim=(0,1), ylim=(0,1))

anim = @animate for _ in 1:nframes
    move_circles!(circles)
    plot(circles; plot_kwargs...)
end
gif(anim, "anim.gif")

```

![anim](https://global.discourse-cdn.com/julialang/original/3X/9/6/969280fb8ad570340629a4f658b97db47078762f.gif)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-plot-circles-with-given-radii-using-plots/47845)._
