Is it possible to add the coloring range as legend?
You can extract the Point
primitives and their styles from ListPointPlot3D
output and use them to construct a PointLegend
:
lpp = ListPointPlot3D[pointsChar,
ColorFunction -> Function[{x, y, z}, Hue[Sqrt[x^2 + y^2 + z^2]]],
Filling -> Axis, BoxRatios -> {1, 1, 1},
PlotStyle -> PointSize[Large]];
legend = PointLegend[## & @@ Transpose[Cases[lpp, {a_, Point[b_]} :> {a, b}, ∞]],
LegendMarkerSize -> 20];
Legended[lpp, legend]
ClearAll["Global`*"]
pointsChar = {{0.`, 0.`, 41.63`}, {8.50479382206883`, 0.`,
31.74032265185878`}, {14.975`, 0.`,
25.937460843343935`}, {19.69999492385721`, 0.`,
19.69999492385721`}, {23.053596248741755`, 0.`,
13.31`}, {25.12373074177866`, 0.`, 6.731883363116563`}, {26.16`, 0.`,
0.`}, {26.205567667222418`,
0.`, -7.0217606936313866`}, {24.595121467478055`,
0.`, -14.2`}, {21.630396436496486`, 0.`, -21.630396436496486`}, {16.62`,
0.`, -28.786684421794742`}, {10.396761041768258`,
0.`, -38.80124044203187`}};
{minDist, maxDist} = MinMax[EuclideanDistance[{0, 0, 0}, #] & /@ pointsChar];
Since colors given by Hue
are the same for min and max values, an alternative color function may be desired. Further, the EuclideanDistance
is given in the Tooltip
.
Manipulate[
Legended[
ListPointPlot3D[
Tooltip[#, EuclideanDistance[{0, 0, 0}, #]] & /@
pointsChar,
ColorFunction ->
Function[{x, y, z},
If[cf === Hue, Hue, ColorData[cf]][
Rescale[Sqrt[x^2 + y^2 + z^2], {minDist, maxDist}]]],
ColorFunctionScaling -> False,
Filling -> Axis,
BoxRatios -> {1, 1, 1},
PlotStyle -> PointSize[Large]],
BarLegend[{If[cf === Hue, Hue,
ColorData[cf][Rescale[#, {minDist, maxDist}]] &], {minDist, maxDist}}]],
{{cf, Hue, "ColorFunction"}, {Hue, "Rainbow", "TemperatureMap"}}]