# How to align the plot legends in the following way?

Consider example

   ContourPlot[{(x - 2)^2 + (y - 2)^2 ==
12, (x + 2)^3 + (y + 2)^3 ==8}, {x, -4, 4}, {y, -4, 4},
PlotLegends ->
Placed[{Style["Region 1", 20], Style["Region 2", 20]}, {0.7, 0.82}]]


The result is the picture on the left. Could you please tell me to change the colour of the legend text and set for each plot legend set its own coordinate, see the picture on the right?

Try this:

Show[{
ContourPlot[{(x - 2)^2 + (y - 2)^2 == 12, (x + 2)^3 + (y + 2)^3 ==
8}, {x, -4, 4}, {y, -4, 4}, ContourStyle -> {Blue, Orange}],
Graphics[{Text[Style["Region 1", 20, Blue], Scaled[{0.8, 0.8}]],

Text[Style["Region 2", 20, Orange], Scaled[{0.2, 0.2}]]
}]
}]


Done. Have fun!

• Maybe a bit more "authomatic": Show[ContourPlot[(x - 2)^2 + (y - 2)^2 == 12, {x, -4, 4}, {y, -4, 4}, ContourStyle -> Blue, PlotLegends -> Placed[{"Region 1"}, {Right, Top}]], ContourPlot[(x + 2)^3 + (y + 2)^3 == 8, {x, -4, 4}, {y, -4, 4}, ContourStyle -> Orange, PlotLegends -> Placed[{"Region 2"}, {Left, Bottom}]]] – b.gates.you.know.what Nov 1 '18 at 10:04
labels = Style[#, 20] & /@ {"Region 1", "Region 2"};
colors = ColorData[97] /@ {1, 2};
positions = {{7, 7} / 10, {1, 1} / 4};

ContourPlot[{(x - 2)^2 + (y - 2)^2 == 12, (x + 2)^3 + (y + 2)^3 ==  8},
{x, -4, 4}, {y, -4, 4},
PlotLegends -> ( Placed[Style@##2, #] & @@@ Transpose[{positions, labels, colors}])]


Alternatively, you can replace PlotLegends -> ... with

Epilog -> (Text[Style[##2], Scaled@#] & @@@ Transpose[{positions, labels, colors}])


to get the same picture.

Update: You can also get positions using ImplicitRegion and RegionCentroid :

contours = {(x - 2)^2 + (y - 2)^2 == 12, (x + 2)^3 + (y + 2)^3 == 8} ;
positions = Quiet @ N @ RegionCentroid[ImplicitRegion[# /.
Equal -> LessEqual, {{x, -4, 4}, {y, -4, 4} }] ] & /@ contours


{{1.46315, 1.46315}, {-2.03791, -2.03791}}

Notes: (1) Despite the warning message (suppressed above with Quiet) RegionCentroid gives the correct coordinates. (2) If you use this with Epilog you should remove Scaled.

• Nice answer, first time I've ever seen ##n used. – N.J.Evans Nov 1 '18 at 15:16