10
$\begingroup$

I am trying to add labels to a plot in specific positions. I give a simple example:

Plot[1 - x^2, {x, -1, 1},
    PlotLabels -> Placed[{"A", "B", "C"},
    {{-1,Left},{0, Above}, {1, Right}}]]

So I would like to have the labels A, B, C at the locations x=-1,0,1 of the plot. I know of "Above", "Below", "Left", "Right" as locations for the labels to be placed. However I would like something like "Above Left" or "Above Right", so A and C are not intersecting the x-axis, and B is not intersection the y-axis.

Does that command exist?

Simply choosing the locations Above ±(1+epsilon) does not work, since the plot range is from -1 to 1.

If there is a way to fine-tune the concrete position that would also be nice to know how that works. I actually wouldn't necessarily require labels to a curve, but simply labels at some chosen coordinate in the plot.

Thanks for suggestions!

$\endgroup$
2
  • $\begingroup$ Plot[1 - x^2, {x, -1, 1}, PlotLabels -> Placed[{"A"}, {-1, Left}], PlotRange -> All] works for me as well as simple Plot[1 - x^2, {x, -1, 1}, PlotLabels -> Placed[{"A"}, {Left}], PlotRange -> All]. $\endgroup$
    – Alx
    Commented Oct 11, 2019 at 14:24
  • $\begingroup$ @Alx Thanks for the answer! I meanwhile also found out, that I can just enter the location as coordinates, e.g. {{-1.05,1.05},{…},{…}}. $\endgroup$
    – Britzel
    Commented Oct 11, 2019 at 14:27

1 Answer 1

10
$\begingroup$
Plot[{1 - x^2,1 - x^2,1 - x^2}, {x, -1, 1},
   PlotStyle -> ColorData[97][1], 
   PlotLabels -> Placed[{"A", "B", "C"},
     {{Left, Bottom}, {Right, Bottom}, {Above,Left}}]]

enter image description here

 Plot[{1 - x^2, 1 - x^2, 1 - x^2}, {x, -1, 1},
   PlotStyle -> ColorData[97][1], 
   PlotLabels -> Placed[{"A", "B", "C"},
       {{-1, .1}, {.1, 1}, {1, .1}}]]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks a lot good Sir! $\endgroup$
    – Britzel
    Commented Oct 11, 2019 at 14:35
  • $\begingroup$ @Britzel, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Commented Oct 11, 2019 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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