# Using different Epilog for multiple plots with PlotLayout

I would like to generate several plots like in my example, but use a different Epilog for each plot.

ContourPlot[{Sin[x] + Cos[y], (x)^2 - (y)^2}, {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic, PlotLayout -> "Row"
, Epilog -> {
{Thickness[Large], Red, Circle[{0, 0}, 1.5]},
{Thickness[Large], Blue, Circle[{0, 0}, 0.5]}
}
]


I'd like to have one circle on the left plot, the other circle on the right plot.

deleteUnwantedEpilogs =
Module[{pos = Position[#, HoldPattern[Epilog -> _], All]},
Delete[#, Apply[Join] @
MapIndexed[((x |-> Join[#, {2}, {x}]) /@
Drop[Range@Length@pos, #2]) &] @ pos]] &;


Examples:

cp = ContourPlot[{Sin[x] + Cos[y], (x)^2 - (y)^2}, {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic, PlotLayout -> "Row"
, Epilog -> {
{Thickness[Large], Red, Circle[{0, 0}, 1.5]},
{Thickness[Large], Blue, Circle[{0, 0}, 0.5]}
}
];

deleteUnwantedEpilogs @ cp


deleteUnwantedEpilogs @
ContourPlot[{Sin[x] + Cos[y], (x)^2 - (y)^2, Sin[x y]}, {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic, PlotLayout -> "Row",
Epilog -> {{Thickness[Large], Red, Circle[{0, 0}, 1.5]},
{Thickness[Large], Blue, Circle[{0, 0}, 0.5]},
{Thickness[Large], Green, Circle[{0, 0}, 0.25]}}]


Replace Epilog -> ... with

Epilog ->
{{Thickness[Large], Red, Circle[{0, 0}, 1.5], Purple,  Circle[{0, 0}, .75]},
{Thickness[Large], Blue, Circle[{0, 0}, 0.5], Magenta, Rectangle[{.5, .5}]},
{Thickness[Large], Green, Circle[{0, 0}, 0.25], Cyan, Circle[{0, 0}, 1.25]}}


to get

• Cool, generate all Epilogs and delete the unwanted ones later. I'll happily accept that! Commented Jun 29, 2023 at 9:52
Clear["Global*"]

Legended[
GraphicsGrid[
{ContourPlot[#[[1]],
{x, -2, 2}, {y, -2, 2},
Epilog -> {Thickness[Large], #[[2]], Circle[{0, 0}, #[[3]]]},
ImagePadding -> #[[4]]] & /@ {
{Sin[x] + Cos[y], Red, 1.5, Automatic},
{x^2 - y^2, Blue, 0.5, {{0., 28.7192}, {-1., 25.8194}}}}},
Spacings -> 0],


Something like:

epi1 = {Thickness[Large], Red, Circle[{0, 0}, 1.5]};
epi2 = {Thickness[Large], Blue, Circle[{0, 0}, 0.5]};

Row[{ContourPlot[{Sin[x] + Cos[y]}, {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic, ImageSize -> 200, BoundaryStyle -> Black,
Epilog -> epi1],
ContourPlot[{(x)^2 - (y)^2}, {x, -2, 2}, {y, -2, 2},
PlotLegends -> Automatic, ImageSize -> 200, BoundaryStyle -> Black,
Epilog -> epi2]
}]
`

• This creates to separate axes and two separate legends, which I tried to avoid. With PlotLayout, I'll get the same legend for both plots and a common color scale Commented Jun 29, 2023 at 9:50