1
$\begingroup$

I would like to plot two ListDensityPlot3D plots in the same plot. My two data sets are intersecting, and I would like to see that the two shapes intersect. However, when I plot them only one is visible. Here is the code to reproduce my results, the data being plotted is coordPhi and coordPhi2:

X = Table[(2*15./(2*60 + 1))*i, {i, -60, 60}];
Y = Table[(2*15./(2*60 + 1))*i, {i, -60, 60}];
Z = Table[-14. + 2*14/60*i, {i, 0, 60}];
coordPhi = 
  Flatten[Table[{X[[i]], Y[[j]], Z[[k]], 
     E^(-(X[[i]]^2 + Y[[j]]^2 + Z[[k]]^2))}, {i, 1, 121}, {j, 1, 
     121}, {k, 1, 61}], 2];
coordPhi2 = 
  Flatten[Table[{X[[i]] + 2, Y[[j]] + 2, Z[[k]] + 2, 
     E^(-(X[[i]]^2 + Y[[j]]^2 + Z[[k]]^2))}, {i, 1, 121}, {j, 1, 
     121}, {k, 1, 61}], 2];
p1 = ListDensityPlot3D[coordPhi];
p2 = ListDensityPlot3D[coordPhi2];
Show[p1, p2, PlotRange -> {{-10, 10}, {0, 10}, {-10, 10}}, 
 PlotLegends -> Automatic]
$\endgroup$
0

1 Answer 1

1
$\begingroup$

Try using an "OpacityFunction" like:

p1 = ListDensityPlot3D[coordPhi, OpacityFunction -> (0.2 &), 
   ColorFunction -> Function[{z}, Hue[z]]];
p2 = ListDensityPlot3D[coordPhi2, OpacityFunction -> (0.2 &)];
Show[p2, p1, PlotRange -> {{-10, 10}, {0, 10}, {-10, 10}}, 
 PlotLegends -> Automatic]

enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ When i do this, all I see plotted is p2 $\endgroup$
    – Zonova
    Oct 4, 2022 at 13:19
  • $\begingroup$ I think we have a version problem. The plot above was done using 13.1. $\endgroup$ Oct 4, 2022 at 13:41
  • 1
    $\begingroup$ Your plot also only shows p2 I believe. If it showed p1 as well, then there would be two different blobs. $\endgroup$
    – Zonova
    Oct 4, 2022 at 14:41
  • $\begingroup$ I think you are mistaken. p2 looks like a ball, my plot looks like a rugby ball. $\endgroup$ Oct 4, 2022 at 15:01
  • 1
    $\begingroup$ It looks like a rugby ball due to being stretched in the z direction, if you plot in the range PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}, you will see one normal ball I believe. $\endgroup$
    – Zonova
    Oct 4, 2022 at 15:38

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.