Plot a circle with a given radius with Plots.jl

I can’t figure out how to plot circles with given radii.
I would like the radius to be given as floats with plots units (not integers).
I try to play with markersize but the display sizes do not correspond to xy units.
Any hints?



There might exist simpler solutions, but parametric curves probably cover your needs


There is an unexported partialcircle function that can also plot a whole circle

1 Like

Thank you very much !

I came across partialcircle but I though that there might be an obvious solution like an annotation to express the markersize in plot units.

Besides, partialcircle seems to take integer arguments… I will use the parametric function solution.

I usually use this.


Thank you, this is more elegant !

Ir rocks :wink:toto


That’s very cool. Did you do this using Plots? Is the code available?

1 Like

Thanx !
Yes it is Plots.
At first I used Makie but we are preparing introductory Julia hands-on sessions and lately we experienced a lot of installation problems (Cairo?) that are difficult to handle on multiple heterogeneous student laptops.
The code is not yet ready for sharing but it is mainly based on Chris Hecker tutorial.

The idea is to illustrates the power of Julia’s type system and multiple dispatch on a funny example. A hierarchy of 2D shapes and a bunch of methods for the contact function.


The resulting Julia’s code is quite compact and performant and I think it gives a pretty convincing demonstration of Julia’s strength compared to other languages. In particular, for matlab users that may not be very experienced with types.

I still wonder about the best Julian way to handle multiple plotting backends (Makie/Plots) that prevents from depending on both packages (toml).


Are you checking all pairwise collisions, or using one of the acceleration techniques like dividing into cells?

1 Like

Yes. Keep in mind that it is a Julia lecture material and not a simulation package :wink:

For the bigger time step, I use an N² overlap check on bounding boxes. From there, overlapping shapes recursively divide their time steps until true contact is reached. Then (hopefully) binary collisions are computed and velocities updated.This sequential code run rather smoothly up to 300 bodies.
BTW I wonder how python or matlab experts would have implement this kind of code. I guess that recursive binary contact may not be that easy to express efficiently with “vectorized” (not SIMD) style…

1 Like

Is your code now available?



That is so helpful! Thank you.

1 Like

Take a look at (any suggestions are welcome, I do have a lot of examples around). I just need to know what the community is looking for. Cheers !

1 Like


How would I plot this shape in 3d? Imagine a circular plane

Kind regards

Linking related posts for some 3D disk solutions using Plots.jl and Makie.jl.

1 Like


Did you ever finish this code well enough to release it?