I need to add arrows & text that determine which function has the highest value in a given region. I do not even know where to start. Imagine I have the following plot:

  line1 = Line[{{.292893, 0}, {.292893, 2}}];
line2 = Line[{{.75, 0}, {.75, 2}}];
Plot[
{.5 x^2 + 1, x + .75, 2 x}, {x, 0, 1},
Epilog -> {line1, line2}
]


And this is what I need:

Thanks a lot!

line1 = Line[{{.292893, 0}, {.292893, 2}}];
line2 = Line[{{.75, 0}, {.75, 2}}];
arrow = {
Arrow[{{0, -0.1}, {.292893, -0.1}}],
Arrow[{{.292893, -0.1}, {.75, -0.1}}],
Arrow[{{.75, -0.1}, {1, -0.1}}]
};
text = {Text["region A", {.292893/2, -0.4}],
Text["region B", {.53, -0.4}],
Text["region C", {.89, -0.4}]
};
Plot[{.5 x^2 + 1, x + .75, 2 x}, {x, 0, 1},
PlotRange -> {Automatic, {-1, 2}} ,
Epilog -> {line1, line2, arrow, text}]


• Thanks a lot! I thought about something that is separate and not in the plot. But of course, this is also a way to do it! Jan 20 '20 at 12:11
• @KarlA, take a look at kglr’s use of labeled arrows, you might save yourself a lot of finagling to get the text positioning as you would like it. Very nice answer though, wuyudi! Jan 20 '20 at 21:30

You can also add text labels using custom Arrowheads:

ClearAll[arrowHeads, labeledArrows]
{Automatic, Automatic, Graphics @ Text[#, {0, 0}, {0, offset}]},
size}] & /@ lbls;

labeledArrows[lbls_, lst_,  offset_: 2, size_: .04] := MapThread[
List, {arrowHeads[lbls, offset, size], Arrow /@ Partition[lst, 2, 1]}];


Examples:

labels = {"region 1", "region 2", "region 3"};
list = Thread[{{0, .29, .75, 1}, -.25}];

Plot[{.5 x^2 + 1, x + .75, 2 x}, {x, 0, 1},
PlotRangePadding -> 0, PlotRangeClipping -> False,
ImagePadding -> {{Automatic, Automatic}, {Scaled[.05], Scaled[.03]}},
GridLines -> {{.292893, .75}, None},
Epilog -> labeledArrows[labels, list]]


You can add styling directives and use the third and fourth arguments to control the label position and the size of the arrow glyph, respectively:

Plot[{.5 x^2 + 1, x + .75, 2 x}, {x, 0, 1},
PlotRangePadding -> 0, PlotRangeClipping -> False,
ImagePadding -> {{Automatic, Automatic}, {Scaled[.05], Scaled[.03]}},
GridLines -> {{.292893, .75}, None},
Epilog -> {{labeledArrows[labels, list],
Dashed, labeledArrows[{"region 4"}, {{.29, 2 .29 - .1}, {.75, 2 .75 - .1}}],
Dotted, Red, FontColor -> Purple, FontSize -> 12,
labeledArrows[{"label 1", "label 2", "label 3"},
Thread[{{0, .29, .75, 1}, 2.1}], -1, .06]}}]


Update: An alternative way to use labeledArrows is to generate a graphics object and use Grid to show it under the main plot. (Note the use of special settings for ImageSize, PlotRangePadding and ImagePadding to align the two graphics objects):

options = {ImageSize -> 1 -> 400, PlotRangePadding -> 0,
ImagePadding -> {{Automatic, 10}, {Automatic, Automatic}}};

plot = Plot[{.5 x^2 + 1, x + .75, 2 x}, {x, 0, 1},
GridLines -> {{.292893, .75}, None}, Evaluate @ options];

arrowsandlabels = Graphics[labeledArrows[labels, Thread[{{0, .29, .75, 1}, 0}]],
PlotRange -> {{0, 1}, {-.05, 0.01}}, Evaluate @ options];

Grid[{{plot}, {arrowsandlabels}}, Alignment -> Right, Spacings -> {None, 1}]