3

Bug introduced in 10.0.0 and fixed in 10.0.1


For some weird reason, they apparently changed the styling of contours in ContourPlot for 10.0. Here is a comparison of the results for V9 and V10 (first 9, then 10):

ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, 
    ContourShading -> None,  ContourStyle -> {{Red, Thickness[0.008]}}]

Mathematica 9 output Version 9

Mathematica 10 output Version 10

Firstly, can I override the coloring? I would like to keep the solid colors that were in V9. And secondly, where do those dark spots come from? Is this a bug?

Edit: yes, this does look like a bug. The dark spots are only visible in the Mac version.

Interestingly enough, for about half a second after the output appears, what I see on the screen is similar to what Export produces (shown below). The only difference is that the lines are thinner in the exported .png (another bug?). After those 0.5 seconds, another level of transparency kicks in and I see what is shown in the top picture below.

ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, 
    Contours -> {.9}, ContourShading -> None, 
    ContourStyle -> {{Red, Thickness[0.17]}}]

enter image description here <- What I see. enter image description here <- What Export produces.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Alex Bogatskiy
  • 1,680
  • 12
  • 19

2 Answers2

6

I propose two possible solutions:

  1. Turn off transparency by including Opacity[1] in the CountourStyle

  2. Use CapForm["Butt"] to prevent the line caps from overlapping. With this solution you can keep transparency on, and the result will look like:

With CapForm["Butt"] theoretically there can still be a slight misalignment, or crack between the lines, but this is unlikely to be visible in practice.


Edit: Another possible solution is adding the option Method -> {"TransparentPolygonMesh" -> True}, as described here. I don't know what this does exactly.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
  • Wow, this is a pretty neat solution. Is there a way to tell if they actually use "Butt" automatically in the Windows version? Or anything else.. – Alex Bogatskiy Jul 10 '14 at 15:44
  • @level1807 You could try all possible values in the Windows version and see if it makes a difference. If it does not make a difference, then the most likely explanation is that lines that are specified together, as a single Line primitive, are also rendered together by Windows, and transparency is added only after all lines have been rendered. I would compare Graphics@{Thickness[0.2], Opacity[0.5], Line[{{{-1, 0}, {1, 0}}, {{0, -1}, {0, 1}}}]} with Graphics@{Thickness[0.2], Opacity[0.5], Line[{{-1, 0}, {1, 0}}], Line[{{0, -1}, {0, 1}}]} on both Windows and Mac. – Szabolcs Jul 10 '14 at 15:54
  • @level1807 See my update. – Szabolcs Jul 10 '14 at 16:00
3

I don't know if this help or not but here is what I got for you.

ContourPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}, ContourShading -> None, 
 ContourStyle -> {{Red, Thickness[0.008]}}, PlotTheme -> None]

enter image description here

Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
  • Wow, I didn't think this is None =) Apparently Opacity[1] already gave the save effect, but thanks. This question has now transformed into a discussion of rendering bugs. – Alex Bogatskiy Jul 11 '14 at 16:01