8
$\begingroup$

Bug introduced in 12.0 or earlier and persisting in 14.0.

Was temporarily fixed in 12.3, but regressed again in 13.0.


Simply do this

ListPlot[Range[1500], PlotRange -> All, 
 PlotStyle -> {{Thickness[0.02], Opacity[0.5, Black]}}, 
 Joined -> True, Frame -> True]

we obtain

enter image description here

What's wrong with this darker segments each 500 point?

$\endgroup$
9
  • 1
    $\begingroup$ I do not see this problem on macOS with Mathematica 12.3.1. It may be a platform-specific rendering issue. Please indicate your OS and Mathematica version. You might try using fewer plot points and see if it helps. It looks like there are more points than the width of the image in pixels. Try MaxPlotPoints. $\endgroup$
    – Szabolcs
    Commented Jul 12, 2021 at 12:03
  • 1
    $\begingroup$ No such problem on Linux or Windows 11 with Mathematica 12.3.1. $\endgroup$
    – cvgmt
    Commented Jul 12, 2021 at 12:10
  • 1
    $\begingroup$ @JulesLamers Confirmed with 13.3.1 on macOS. Can't test with earlier versions at the moment. $\endgroup$
    – Szabolcs
    Commented Sep 20, 2023 at 19:55
  • 1
    $\begingroup$ @JulesLamers No, I'll report it as well. $\endgroup$
    – Szabolcs
    Commented Sep 21, 2023 at 18:00
  • 1
    $\begingroup$ I see this in every version except 12.3. Note that this is likely macOS-specific. $\endgroup$
    – Szabolcs
    Commented Sep 21, 2023 at 18:06

2 Answers 2

5
$\begingroup$

I can reproduce this using Mathematica 12.2 on macOS, but not using Mathematica 12.3.1. I believe it is a rendering bug.

enter image description here

Simply copying the graphics expression between a 12.3 and a 12.2 notebook makes the problem appear/disappear, which shows that the issue is specific to graphics rendering.


It seems that the problem appears whenever there is a Line with a large number of points, and Opacity of less than 1. Perhaps the line is broken to smaller pieces internally and what we see if the overlap between these pieces?

A simpler example to reproduce the problem is:

Graphics[{Thickness[0.02], GrayLevel[0, 0.5], 
  Line[Table[{k, k}, {k, 1000}]]}]

One possible workaround is to reduce the number of points. Unfortunately, there is a risk that the plot quality will be reduces as well. I suggest that you experiment with MaxPlotPoints settings. I need to use MaxPlotPoints -> 100 or less on my machine to make the problem go away, showing that the Line is broken to pieces with 100 points each. It looks like on your machine this value may be closed to 500 (as I see three overlaps for 1500 points). 500 should be sufficient for most plots.


I expect someone might be able to produce a workaround using undocumented Graphics rendering options. I suggest you contact Wolfram Support and if they give you a better workaround, post it here.

$\endgroup$
1
  • 1
    $\begingroup$ Wolfram Technical Support got back to me with a workaround, see below $\endgroup$ Commented Sep 26, 2023 at 19:46
4
$\begingroup$

This bug for MacOS seems to have persisted in all recent versions except for 12.3.1 (cf the comments to the OP). I've reported it to Mma. For now they advise a way around the problem that does indeed seem to work:

In the meantime, there is a workaround that you can try or suggest to your colleagues working on macOS. Please include the CapForm["Butt"] to the PlotStyle option:

ListPlot[Range[1500], PlotRange -> All, PlotStyle -> {{CapForm["Butt"],Thickness[0.02], Opacity[0.5, Black]}}, Joined -> True, Frame -> True]

$\endgroup$

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.