1
$\begingroup$

I am having problems with setting the opacity of callout labels when plotting. Strangely, it only seems to work when the text color is red. In the following example, the odd labels should be 0.2 opacity, but as you can see it only works for red.

Plot[{
  Callout[Sin[x], "Boo", Above, LabelStyle -> {Red, Opacity[0.2]}],
  Callout[Sin[x - 0.2], "Boo", Above, 
   LabelStyle -> {Red, Opacity[1.0]}],
  Callout[Sin[x - 0.4], "Boo", Above, 
   LabelStyle -> {Black, Opacity[0.2]}],
  Callout[Sin[x - 0.6], "Boo", Above, 
   LabelStyle -> {Black, Opacity[1.0]}],
  Callout[Sin[x - 0.8], "Boo", Above, 
   LabelStyle -> {Blue, Opacity[0.2]}],
  Callout[Sin[x - 1.0], "Boo", Above, 
   LabelStyle -> {Blue, Opacity[1.0]}],
  }, {x, 0, Pi}]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ It is a bug. When you look at FullForm of output you can see List[RGBColor[1, 0, 0], Opacity[0.2]]` for red color and List[RGBColor[0, 0, 1], Opacity[0.2], Opacity[1]] for blue color. For some reason Mathematica appends Opacity[1] after Opacity[0.2] which overrides the previous opacity setting. $\endgroup$ Aug 7, 2022 at 10:34

2 Answers 2

1
$\begingroup$

Here is a workaround for the bug:

Plot[{Callout[Sin[x], "Boo", Above, 
    LabelStyle -> {Red, Opacity[0.2]}], 
   Callout[Sin[x - 0.2], "Boo", Above, 
    LabelStyle -> {Red, Opacity[1.0]}], 
   Callout[Sin[x - 0.4], "Boo", Above, 
    LabelStyle -> {Black, Opacity[0.2]}], 
   Callout[Sin[x - 0.6], "Boo", Above, 
    LabelStyle -> {Black, Opacity[1.0]}], 
   Callout[Sin[x - 0.8], "Boo", Above, 
    LabelStyle -> {Blue, Opacity[0.2]}], 
   Callout[Sin[x - 1.0], "Boo", Above, 
    LabelStyle -> {Blue, Opacity[1.0]}]}, {x, 0, 
   Pi}] /. {PatternSequence[x__, Opacity[y_], Opacity[1]]} -> {x, 
   Opacity[y]}
$\endgroup$
0
$\begingroup$

Your code works fine for me (v. 11.3, MacOS):

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks. I'm on v13.1.0.0, MacOS. $\endgroup$
    – yirenng
    Aug 7, 2022 at 5:46
  • $\begingroup$ Same problem on Windows 13.1 $\endgroup$ Aug 7, 2022 at 7:44
  • $\begingroup$ it is not working only for some colors. If we replace Blue/Black with Orange it works. STRANG! $\endgroup$
    – MMA13
    Aug 8, 2022 at 8:42

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.