I have been trying to modify a clipped graph by adding a text a label outside the frame, with no success so far.
Code for contour
per request to get the rest of the code to run:
ClearAll[Sbase, Vbase, Zbase, countour];
Sbase = 50 10^3;
Vbase = 240;
Zbase = Vbase^2/Sbase;
countour[M_, Zpu_, XR_] :=
Circle[{M/Z Cos[\[Phi]], -M/Z Sin[\[Phi]]}, 1/Z] /. {Z -> Zpu Zbase, \[Phi] -> ArcTan[XR]}
This is my graph:
g1 = Graphics[
Flatten[
{Red,
Table[countour[M, 0.02, 3], {M, 0.98, 1.02, 0.001}],
Blue,
Table[countour[M, 0.04, 1], {M, 0.98, 1.02, 0.001}]
}
],
Axes -> True, PlotRangeClipping -> True, AxesStyle -> Thick,
AxesLabel -> {x, y}, ImagePadding -> {{All, 50}, {All, All}},
Frame -> True, PlotRange -> {{-0.3, 0.3}, {-0.3, 0.3}}];
The contour
function just produces circles with differing centers and radii. I am zooming in close to the origin and clipping everything else to get this:
All is fine up to now, but I also want to add text labels outside the clipped frame. My successful trials, along with what I see suggested online(including StackExchange), hinge on setting PlotRangeClipping
to False
, for example as suggested here: "insert a text outside the frame".
That does not work for me, because when I try it I get:
ClearAll[g1, addLabel];
addLabel = Show[#,
Epilog -> Text[#2, Scaled[{1.02, 0.7}], {-1, -1}],
PlotRangeClipping -> False,
ImagePadding -> {{All, 50}, {All, All}}] &;
g1 = Graphics[
Flatten[
{Red,
Table[countour[M, 0.02, 3], {M, 0.98, 1.02, 0.001}],
Blue,
Table[countour[M, 0.04, 1], {M, 0.98, 1.02, 0.001}]
}
],
Axes -> True, AxesStyle -> Thick, AxesLabel -> {x, y},
Frame -> True, PlotRange -> {{-0.3, 0.3}, {-0.3, 0.3}}];
addLabel[g1, Style["M\[Equal]1", 16, Red]]
Which is not what I want at all. If I try to keep PlotRangeClipping
as 'True` I lose the text label.
Any recommended workarounds ?