1
$\begingroup$

I have a small number of points in 3D space. Each point has an associated weight (real number). For each point, I want to plot a [visible point] whose color is a function of the weight value.

It seems like ListDensityPlot3D would work for this, but I just get a blank space and I think this is because the points are spaced so far apart and I cannot find an PointSize option for ListDensityPlot3D.

My closest work around is to use Graphics3D and Point, but I cannot use a BarLegend because "BarLegend is not a Graphics3D primitive or directive".

I have pasted my workaround and my attempt at using ListDensityPlot3D.

x = {0, -0.1, 0};
y = {0, 0.8, 0};
z = {0, -0.5, 1};
T = {90.9, 57.7, 0};

Graphics3D[{
  Table[
   {Hue[T[[i]]], PointSize[0.03],
    Point[
     {x[[i]], y[[i]], z[[i]]}
     ]},
   {i, 1, 3}],
  Opacity[0.05], Cuboid[{-1, -1, -1}, {1, 1, 1}]},
 Axes -> True, AspectRatio -> 1
 ]

ListDensityPlot3D[
 Table[{x[[i]], y[[i]], z[[i]], T[[i]]}, {i, 1, 3}]
 ]
$\endgroup$

2 Answers 2

3
$\begingroup$
BubbleChart3D[Thread[{x, y, z, 1}], 
 BubbleSizes -> Medium, 
 Boxed -> True,
 ChartStyle -> (ColorData["Rainbow"] /@ Rescale[T]), 
 ChartLegends -> SwatchLegend[T, LegendMarkers -> "Bubble"],
 FaceGrids -> {}]

enter image description here

$\endgroup$
2
$\begingroup$
ListPointPlot3D[
 List /@ Transpose[{x, y, z}],
 PlotStyle -> {Red, Blue, Green},
 PlotLegends -> T
 ]

Output

$\endgroup$
2
  • $\begingroup$ PlotLegends -> T would be more descriptive. $\endgroup$
    – Bob Hanlon
    Jul 15, 2020 at 21:22
  • $\begingroup$ @BobHanlon Updated. $\endgroup$
    – C. E.
    Jul 16, 2020 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.