1
$\begingroup$

How do I label a point that I add to a plot of some kind using Show[plot,Graphics[...]], from the documentation I cannot find out the correct way. I would have thought that the following would work but it produces an error:

Show[RegionPlot[x > y, {x, -2, 2}, {y, -2, 2}],
 Labeled[Graphics[{Red, Point[{1/6, 1/3}]}] , "a"]
 ]

(See also this closed question: Placing a label at a point, which was judged off-topic even though it looks completely on-topic too me.)

$\endgroup$
2
  • $\begingroup$ Show[RegionPlot[x > y, {x, -2, 2}, {y, -2, 2}], Graphics[{Red, Point[{1/6, 1/3}], Black, Text["a", {1/6 - .1, 1/3}]}]] or RegionPlot[x > y, {x, -2, 2}, {y, -2, 2}, Epilog -> {Red, Point[{1/6, 1/3}], Black, Text["a", {1/6 - .1, 1/3}]}] $\endgroup$ Nov 5 '20 at 16:59
  • $\begingroup$ @RohitNamjoshi, thanks! I think I consider that a full answer so you could put it as an answer if you want to. $\endgroup$
    – Kvothe
    Nov 5 '20 at 17:10
2
$\begingroup$

It does not work because Labeled is not a Graphics primitive or directive. Some alternatives

Using the Text primitive and Show

Show[
 RegionPlot[x > y, {x, -2, 2}, {y, -2, 2}],
 Graphics[{Red, Point[{1/6, 1/3}], Black, Text["a", {1/6 - .1, 1/3}]}]]

enter image description here

Using Epilog

RegionPlot[x > y, {x, -2, 2}, {y, -2, 2},
 Epilog -> {Red, Point[{1/6, 1/3}], Black, Text["a", {1/6 - .1, 1/3}]}]

The result is the same as using Show.

Using ListPlot, Callout and Show

Show[RegionPlot[x > y, {x, -2, 2}, {y, -2, 2}], 
 ListPlot[Callout[{{1/6, 1/3}}, "a", Left], Axes -> False, PlotStyle -> Red]]

enter image description here

With Callout there are many options for customizing the appearance.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.