3
$\begingroup$

I'm trying to connect pairs of corresponding points from two lists in a ListPointPlot3D (similar to what was done here but in 3D). Filling-> {1->{2}} isn't working for me, so I presume the problem must lie in how I'm passing the two lists.

SeedRandom[11];
sigma = DiagonalMatrix[{0.001, 0.001, 0.000001}];
sp = 5;
means1 = Flatten /@ 
   Transpose[{Table[RandomReal[{0, 1}, 2], {sp}], Table[0.8, {sp}]}];
dist1 = MixtureDistribution[Table[1, {sp}],
   Table[MultinormalDistribution[means1[[i]], sigma], {i, 
     Table[j, {j, sp}]}]
   ];
means2 = Flatten /@ 
   Transpose[{Table[RandomReal[{0, 1}, 2], {sp}], Table[0.2, {sp}]}];
dist2 = MixtureDistribution[Table[1, {sp}],
   Table[MultinormalDistribution[means2[[i]], sigma], {i, 
     Table[j, {j, sp}]}]
   ];
n = 50;
data1 = RandomVariate[dist1, n];
data2 = RandomVariate[dist2, n];
ListPointPlot3D[{data1, data2}, PlotRange -> {{0, 1}, {0, 1}, {0, 1}},
  Filling -> {1 -> {2}}]
$\endgroup$
1
  • $\begingroup$ Almost! What I'd like to for each point in the top layer to be connected to only one point in the bottom layer. Which point is connected to which is determined by their position (order) in the data (i.e. first point in data1 connects to first point in data2). thanks $\endgroup$
    – user12734
    Commented May 3, 2019 at 22:06

1 Answer 1

0
$\begingroup$

The following might be useful for others to see my mistake:

SeedRandom[11];
sp = 4;
maxVar = 0.02;
means = Table[RandomReal[{0, 1}, 2], {sp}];
dist = MixtureDistribution[Table[1, {sp}],
   Table[BinormalDistribution[means[[i]], 
     RandomReal[{0.01, maxVar}, 2], 0.5], {i, Table[j, {j, sp}]}]
   ];
n = 50;
pos = RandomVariate[dist, n];
data1 = Flatten /@ Transpose[{pos, Table[0.8, {n}]}];
data2 = Flatten /@ Transpose[{pos, Table[0.2, {n}]}];

Show[ListPointPlot3D[{data1, data2}, PlotStyle -> {Red, Blue}, 
  PlotLegends -> {"data1", "data2"}], 
 Graphics3D[{Gray, Line@Transpose[{data1, data2}]}]]
$\endgroup$

Your Answer

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

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