4
$\begingroup$

Take this example:

Plot[Callout[Sin[x], Sin[x], Above], {x, 0, Pi}]

Mathematica graphics

Question: How can I change the length of the line connecting the $\sin(x)$ label with the plotted curve?

I believe this line is called the "leader" and it can be modified with the LeaderSize option. But adding either LeaderSize -> 10 or LeaderSize -> {10} to Callout makes no difference.

Motivation: When the plot has a wide aspect ratio, the leaders tend to be too long. I assume this is because they are computed relative to the figure width.

Plot[Callout[Sin[x], Sin[x], Above], {x, 0, Pi}, AspectRatio -> 1/4]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ i don't know why but it seems that the both the leader and the neck change only if you set the position to Automatic : Plot[Callout[Sin[x], Sin[x], Automatic, LeaderSize -> {{70, 0, 0}, {10, 0, 0}}], {x, 0, Pi}, AspectRatio -> 1/4] $\endgroup$ – Alucard Sep 3 '17 at 14:55
2
$\begingroup$

Here is a workaround (besides the obvious one of specifying an explicit coordinate instead of Above) where I shrink the neck size:

Plot[
    Callout[
        Sin[x],
        Rotate[Sin[x], -Pi/2],
        Above,
        FrameMargins -> 0,
        LeaderSize -> {Automatic, {0, Pi/2}}
    ],
    {x, 0, Pi},
    AspectRatio -> 1/4
]

enter image description here

Another possibility is to bend the callout:

Plot[
    Callout[
        Sin[x],
        Sin[x],
        Above,
        LeaderSize -> {Automatic, {0, Pi/4}}
    ],
    {x, 0, Pi},
    AspectRatio -> 1/4
]

enter image description here

$\endgroup$
2
$\begingroup$

maybe help:

Table[Plot[
  Callout[Sin[x], Sin[x], Above, 
   LeaderSize -> {100, 90 \[Degree], i}], {x, 0, Pi}, 
  PlotRange -> Full], {i, 0, 30, 5}]

enter image description here

or

Manipulate[
 Plot[Callout[Sin[x], "Sin[x]", {Pi/2, a}, Pi/2], {x, 0, Pi}, 
  PlotRange -> {Automatic, {0, 2}}], {a, 1.1, 1.75}]
$\endgroup$
  • 1
    $\begingroup$ Please add a plot demonstrating the effect of your code. $\endgroup$ – bbgodfrey Sep 3 '17 at 14:42
  • $\begingroup$ @bbgodfrey I have re-edited the answer $\endgroup$ – jiaoeyushushu Sep 3 '17 at 15:14
  • 1
    $\begingroup$ Somehow I was hoping for an answer where the label did go further away from the curve, instead of the gap doing so. $\endgroup$ – J. M. will be back soon Sep 3 '17 at 15:32
1
$\begingroup$

Consider specifying position for the callout {pos, epos}

enter image description here

Plot[Callout[Sin[x], "Sin(x)", {N@\[Pi]/2, 2.}, 
CalloutMarker -> "\[EmptyCircle]", CalloutStyle -> Gray], {x, 0, 
Pi}, PlotRange -> {{0, 3}, {0, 3}}]

enter image description here

$\endgroup$
  • $\begingroup$ Here you are explicitly specifying the callout position. LeaderSize has no effect Can you point this out in the answer, and remove the superfluous LeaderSize option (since it does nothing here)? $\endgroup$ – Szabolcs Sep 4 '17 at 8:21
1
$\begingroup$

Using different neck lengths:

 Plot[Callout[Sin[x], Rotate[Sin[x],- 90 Degree], Above, 
   LeaderSize -> {{100, 90 Degree, 0}, {#, 90 Degree}}], {x, 0, Pi}, 
  PlotRange -> Full, ImagePadding->50, ImageSize-> 300] &/@ {0, 30, 70}// Row

enter image description here

$\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.