Weird shading artifacts in ContourPlot3D
Clash 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
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
New contributor
add a comment |Â
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
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
New contributor
add a comment |Â
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
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
New contributor
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
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
plotting color
New contributor
New contributor
New contributor
asked 1 hour ago
Grant Larsen
161
161
New contributor
New contributor
add a comment |Â
add a comment |Â
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]
add a comment |Â
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]
add a comment |Â
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]
add a comment |Â
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]
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]
answered 52 mins ago
Henrik Schumacher
41.1k258124
41.1k258124
add a comment |Â
add a comment |Â
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.
Grant Larsen is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password