3
$\begingroup$

They seem to forget add antialiasing on Filling.

When style is transparent we can see a rough boundary.

When style is not transparent the boundary is overlaid with the curve of plotting function on which the antialiasing is used, so no rough boundary is visible.

Is this the same with newer versions of Mathematica?

$Version
Plot[{Sin[x], Sin[x] + 0.05, Sin[x] + 0.06, 
  Sin[x] + 0.11}, {x, Pi/2 - 0.5, Pi/2 + 0.5}, 
 Filling -> {1 -> {{2}, Red}, 3 -> {{4}, Red}}, 
 PlotStyle -> {Red, Red, Transparent, Transparent}, 
 Background -> Green]

"13.0.1 for Microsoft Windows (64-bit) (January 28, 2022)"

enter image description here

$\endgroup$
1
  • $\begingroup$ Same with V 13.3.0 and Mac OS - also with white Background and increased PlotPoints $\endgroup$
    – eldo
    Apr 21 at 16:26

1 Answer 1

6
$\begingroup$

The same behaviour is observed in "14.0.0 for Microsoft Windows (64-bit) (December 13, 2023)", but you can just simply manually enable Antialiasing for fillings.

Plot[{Sin[x], Sin[x] + 0.05, Sin[x] + 0.06, Sin[x] + 0.11}, {x, 
  Pi/2 - 0.5, Pi/2 + 0.5}, PlotStyle -> None,
 Filling -> {1 -> {{2}, Style[Red, Antialiasing -> True]}, 
             3 -> {{4}, Style[Red, Antialiasing -> True]}}]

enter image description here

To get it working also in 13.3, you can put the Antialiasing in FillingStyle:

Plot[{Sin[x], Sin[x] + 0.05, Sin[x] + 0.06, Sin[x] + 0.11}, {x, 
  Pi/2 - 0.5, Pi/2 + 0.5}, PlotStyle -> None, 
 Filling -> {1 -> {2}, 3 -> {4}}, 
 FillingStyle -> Directive[Opacity[1], Red, Antialiasing -> True]]

or, as you've figured it out yourself in the comments, wrap the whole thing with Style:

Style[Plot[{Sin[x], Sin[x] + 0.05, Sin[x] + 0.06, Sin[x] + 0.11}, {x, 
   Pi/2 - 0.5, Pi/2 + 0.5}, PlotStyle -> None, 
  Filling -> {1 -> {{2}, Red}, 3 -> {{4}, Red}}], 
 Antialiasing -> True]
$\endgroup$
4
  • $\begingroup$ Unfortunately it does not work with my version. Anyway (+1), as it may help others that have your version. $\endgroup$ Apr 21 at 16:40
  • $\begingroup$ It works with 14.0, but not with 13.3 $\endgroup$
    – eldo
    Apr 21 at 16:44
  • $\begingroup$ @Domen But it works if I wrap the whole plot in Style like Style[Plot[ ...], Antialiasing -> True]. Add this to your answer and I will accept it. Anyway it is a bug to me - no relevant reason to not apply antialiasing on fillings. $\endgroup$ Apr 21 at 16:48
  • 1
    $\begingroup$ @Domen It also works on version 13 with Filling -> {1 -> {{2}, Directive[Red, Antialiasing -> True]}} instead of using style. $\endgroup$ Apr 21 at 17:02

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.