7

I was trying to run a code that I saw on a answer for this question

The code is simply

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /.
  Line[l_List] :> {{Red, Polygon[l]}, {Black, Line[l]}}

And the result was supposed to be:

filled circle

However, when I run the same code in Mathematica 10.2 I get this result: filled circle bug

I'm running exactly the same code, no extra global variables. Also, the color Red works perfectly fine in other situations. I've tried RGBColor[1,0,0] and the result is the same.

Similar issues happen with other colors too. Every color is "brighter".

2 Answers2

7

The answer is simple. Per default Mathematica reduces the opacity of the colors. Try the following:

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /. 
 Line[l_List] :> {{Red, Polygon[l]}, {Black, Line[l]}}

% /. _Opacity :> Opacity[1]

If you look at the InputForm of your graphics, you will notice a

FaceForm[Opacity[0.3]]

call right in the front. With this knowledge, you can simply fix it by calling:

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}, 
  PlotStyle -> Opacity[1]] /. 
 Line[l_List] :> {{Red, Polygon[l]}, {Black, Line[l]}}
halirutan
  • 112,764
  • 7
  • 263
  • 474
6

I think using the 2nd argument of Opacity is a slightly simpler way to correct the problem than the methods given by halirutan, although those are perfectly fine.

ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /. 
  Line[l_List] :> {{Opacity[1, Red], Polygon[l]}, {Black, Line[l]}}

plot

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • Explicitly setting the alpha channel is even simpler: ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2 Pi}] /. Line[l_List] :> {{RGBColor[1, 0, 0, 1], Polygon[l]}, {Black, Line[l]}}. – J. M.'s missing motivation May 11 '17 at 10:54