좌표의 함수로 선 채색
Sep 08 2020
3D 좌표의 함수로 선을 채색하고 싶습니다. 다음은 내 코드입니다. 이 그래픽에서는 한 가지 색상을 사용했습니다. 내 목표는 3D 좌표를 기반으로 한 색상 기능을 사용하는 것입니다.
points = RandomReal[{0, 20}, {100, 3}]
graph = Graphics3D[{Hue[0.67, 0.6, 0.6], Line[points]},
PlotRange -> All, BoxRatios -> {1, 1, 1}, ImageSize -> 300]
답변
1 kglr Sep 08 2020 at 04:03
VertexColors두 정점과 관련된 두 가지 색상을 혼합하여 선분에 색상을 지정할 수 있습니다 .
SeedRandom[1]
points = RandomReal[{0, 20}, {100, 3}];
Graphics3D[{Thick, Line[points, VertexColors -> (Hue @@@ Rescale[points])]},
PlotRange -> All, BoxRatios -> {1, 1, 1}, ImageSize -> 300]
또는 처음 3 개 인수에 의존하는 색상 함수와 함께 BSplineFunction+ ParametricPlot3D를 사용할 수 있습니다 .
ParametricPlot3D[BSplineFunction[points, SplineDegree -> 1][t], {t, 0, 1},
ColorFunction -> (Hue[#, #2, #3] &), BoxRatios -> {1, 1, 1},
ImageSize -> 300]