Inserting circles in a plot

How can we insert a circle with an arbitrary radius, thickness and color in an arbitrary position in a plot which is created either by a list or a function (ListPlot or Plot)?

• Look up Prolog and Epilog. Something like: ListLinePlot[{data1, data2}, Epilog -> {Orange, Thick, Circle[center, radius], Circle[otherCenter, otherRadius]}]. – MarcoB May 4 '18 at 16:23

You can also use Offset to control the size (in pixels). With @eyorble's example:

pts = {x,Cos[x]} /. Solve[{Cos[x] == Sin[x],0<x<2 \[Pi]}];
Plot[
{Cos[x], Sin[x]},
{x, 0, 2 \[Pi]},
Epilog->{Red, Circle[pts[[1]], Offset[10]], Blue, Circle[pts[[2]],Offset[10]]}
]


Inset is another way to deal with the aspect ratio:

pts = {x, Cos[x]} /. Solve[{Cos[x] == Sin[x], 0 < x < 2 \[Pi]}];
plot = Plot[{Cos[x], Sin[x]}, {x, 0, 2 \[Pi]}, Epilog -> {
Inset[Graphics@{Red, Circle[{0, 0}, 1]}, pts[[1]], Center, Scaled[.25]],
Inset[Graphics@{Blue,Circle[{0, 0}, 1]}, pts[[2]], Center, Scaled[.25]]}]


Using the method MarcoB suggested in the comments, recreating the above plot is reasonably simple. Find the intersection points and plot circles around them:

pts = {x, Cos[x]} /. Solve[{Cos[x] == Sin[x], 0 < x < 2 π}];
plot = Plot[{Cos[x], Sin[x]}, {x, 0, 2 \[Pi]},
Epilog -> {Red, Circle[pts[[1]], 0.2], Blue, Circle[pts[[2]], 0.3]}]


You'll notice the circles appear vertically elongated. If you wish to have precise circles on your output, you'll need to change either the AspectRatio of the plot, or plot the circles elongated to account for the AspectRatio. The former is pretty simple, but the latter is a little bit trickier so I have implemented it below:

plot = Plot[{Cos[x], Sin[x]}, {x, 0, 2 π},
Epilog -> {Red, Circle[pts[[1]], {1, ImageAspectRatio[plot]} 0.2],
Blue, Circle[pts[[2]], {1, ImageAspectRatio[plot]} 0.5]}]


Note however that this plot depends on the previous output of plot, so you'll need to plot it without the adjusted circles at least once to get it started. There are ways to avoid that issue, but they mostly revolve around determining the image aspect ratio in some other way prior.

Far from as elegant as using code like other answers but if you are just trying to highlight the intersection, drawing tools is pretty quick (right click)