Weird shading artifacts in ContourPlot3D

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












Drawing certain shapes in ContourPlot3D gets these weird little shady artifacts with any colorfunction other than the default:



ContourPlot3D[1/Sqrt[x^2+y^2+z^2],x,-1,1,y,0,1,z,-1,1,Ticks->None,Contours->Range[5],ColorFunction->"TemperatureMap"]


gives



weird shading



while the same thing with the default colors gives smoothly shaded, pretty contours.



I see a lot of articles about weird plotting artifacts, but I haven't found any about this one in particular. Any thoughts on how to get rid of the artifacts?










share|improve this question







New contributor




Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    3
    down vote

    favorite












    Drawing certain shapes in ContourPlot3D gets these weird little shady artifacts with any colorfunction other than the default:



    ContourPlot3D[1/Sqrt[x^2+y^2+z^2],x,-1,1,y,0,1,z,-1,1,Ticks->None,Contours->Range[5],ColorFunction->"TemperatureMap"]


    gives



    weird shading



    while the same thing with the default colors gives smoothly shaded, pretty contours.



    I see a lot of articles about weird plotting artifacts, but I haven't found any about this one in particular. Any thoughts on how to get rid of the artifacts?










    share|improve this question







    New contributor




    Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Drawing certain shapes in ContourPlot3D gets these weird little shady artifacts with any colorfunction other than the default:



      ContourPlot3D[1/Sqrt[x^2+y^2+z^2],x,-1,1,y,0,1,z,-1,1,Ticks->None,Contours->Range[5],ColorFunction->"TemperatureMap"]


      gives



      weird shading



      while the same thing with the default colors gives smoothly shaded, pretty contours.



      I see a lot of articles about weird plotting artifacts, but I haven't found any about this one in particular. Any thoughts on how to get rid of the artifacts?










      share|improve this question







      New contributor




      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Drawing certain shapes in ContourPlot3D gets these weird little shady artifacts with any colorfunction other than the default:



      ContourPlot3D[1/Sqrt[x^2+y^2+z^2],x,-1,1,y,0,1,z,-1,1,Ticks->None,Contours->Range[5],ColorFunction->"TemperatureMap"]


      gives



      weird shading



      while the same thing with the default colors gives smoothly shaded, pretty contours.



      I see a lot of articles about weird plotting artifacts, but I haven't found any about this one in particular. Any thoughts on how to get rid of the artifacts?







      plotting color






      share|improve this question







      New contributor




      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      Grant Larsen

      161




      161




      New contributor




      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Grant Larsen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          For some reason, the VertexColors of the recursively computed vertices are set incorrectly. I think this should be reported to Wolfram Support.



          Anyways, here is a quick fix:



          f = x, y, z [Function] 1/Sqrt[x^2 + y^2 + z^2];
          g = ContourPlot3D[
          f[x, y, z], x, -1, 1, y, 0, 1, z, -1, 1,
          Ticks -> None,
          Contours -> Range[5],
          ColorFunction -> "TemperatureMap"
          ];
          pos = Position[g, _GraphicsComplex][[1]];
          GC = Extract[g, pos];
          colpos = Append[#, 2] & /@ Position[GC, VertexColors -> _][[-1]];
          GC = ReplacePart[GC,
          colpos -> List @@@ (ColorData["TemperatureMap"] /@ Rescale[f @@@ GC[[1]]])
          ];
          ReplacePart[g, pos -> GC]


          enter image description here






          share|improve this answer




















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183336%2fweird-shading-artifacts-in-contourplot3d%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            For some reason, the VertexColors of the recursively computed vertices are set incorrectly. I think this should be reported to Wolfram Support.



            Anyways, here is a quick fix:



            f = x, y, z [Function] 1/Sqrt[x^2 + y^2 + z^2];
            g = ContourPlot3D[
            f[x, y, z], x, -1, 1, y, 0, 1, z, -1, 1,
            Ticks -> None,
            Contours -> Range[5],
            ColorFunction -> "TemperatureMap"
            ];
            pos = Position[g, _GraphicsComplex][[1]];
            GC = Extract[g, pos];
            colpos = Append[#, 2] & /@ Position[GC, VertexColors -> _][[-1]];
            GC = ReplacePart[GC,
            colpos -> List @@@ (ColorData["TemperatureMap"] /@ Rescale[f @@@ GC[[1]]])
            ];
            ReplacePart[g, pos -> GC]


            enter image description here






            share|improve this answer
























              up vote
              2
              down vote













              For some reason, the VertexColors of the recursively computed vertices are set incorrectly. I think this should be reported to Wolfram Support.



              Anyways, here is a quick fix:



              f = x, y, z [Function] 1/Sqrt[x^2 + y^2 + z^2];
              g = ContourPlot3D[
              f[x, y, z], x, -1, 1, y, 0, 1, z, -1, 1,
              Ticks -> None,
              Contours -> Range[5],
              ColorFunction -> "TemperatureMap"
              ];
              pos = Position[g, _GraphicsComplex][[1]];
              GC = Extract[g, pos];
              colpos = Append[#, 2] & /@ Position[GC, VertexColors -> _][[-1]];
              GC = ReplacePart[GC,
              colpos -> List @@@ (ColorData["TemperatureMap"] /@ Rescale[f @@@ GC[[1]]])
              ];
              ReplacePart[g, pos -> GC]


              enter image description here






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                For some reason, the VertexColors of the recursively computed vertices are set incorrectly. I think this should be reported to Wolfram Support.



                Anyways, here is a quick fix:



                f = x, y, z [Function] 1/Sqrt[x^2 + y^2 + z^2];
                g = ContourPlot3D[
                f[x, y, z], x, -1, 1, y, 0, 1, z, -1, 1,
                Ticks -> None,
                Contours -> Range[5],
                ColorFunction -> "TemperatureMap"
                ];
                pos = Position[g, _GraphicsComplex][[1]];
                GC = Extract[g, pos];
                colpos = Append[#, 2] & /@ Position[GC, VertexColors -> _][[-1]];
                GC = ReplacePart[GC,
                colpos -> List @@@ (ColorData["TemperatureMap"] /@ Rescale[f @@@ GC[[1]]])
                ];
                ReplacePart[g, pos -> GC]


                enter image description here






                share|improve this answer












                For some reason, the VertexColors of the recursively computed vertices are set incorrectly. I think this should be reported to Wolfram Support.



                Anyways, here is a quick fix:



                f = x, y, z [Function] 1/Sqrt[x^2 + y^2 + z^2];
                g = ContourPlot3D[
                f[x, y, z], x, -1, 1, y, 0, 1, z, -1, 1,
                Ticks -> None,
                Contours -> Range[5],
                ColorFunction -> "TemperatureMap"
                ];
                pos = Position[g, _GraphicsComplex][[1]];
                GC = Extract[g, pos];
                colpos = Append[#, 2] & /@ Position[GC, VertexColors -> _][[-1]];
                GC = ReplacePart[GC,
                colpos -> List @@@ (ColorData["TemperatureMap"] /@ Rescale[f @@@ GC[[1]]])
                ];
                ReplacePart[g, pos -> GC]


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 52 mins ago









                Henrik Schumacher

                41.1k258124




                41.1k258124




















                    Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.









                     

                    draft saved


                    draft discarded


















                    Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.












                    Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.











                    Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.













                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183336%2fweird-shading-artifacts-in-contourplot3d%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery