2

Suppose I have a plane drawn by ListPlot3D and I have one intersection of that 3D image drawn by ListPlot. How can I combine these two?

MOON
  • 3,864
  • 23
  • 49

2 Answers2

7

I made some data for a ListPlot3D plotting.

data = Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
eq1 = ListPlot3D[data, PlotStyle -> Opacity[0.6],Mesh -> {20, 4, 20}]

Blockquote

eq2 = ListPlot[data[[2]], Joined -> True]

Blockquote'

I selected second list of the data for intersected line.

listplot = Join[{Thickness[0.01], Red},
    Replace[Cases[eq2, Line[a_], -1], {a_, b_} -> {a, 2, b}, {3}]] // 
   Graphics3D;
Show[eq1, listplot]

Blockquote

And you can use Manipulate for showing the full ListPlot lines.

Manipulate[
 Show[
  ListPlot3D[data, PlotStyle -> Opacity[0.6], Mesh -> {0, 4, 0}],
  Graphics3D[Join[{Thickness[0.01], Red},
    Replace[Cases[ListPlot[data[[i]], Joined -> True], Line[_], -1], {a_, b_} -> {a, i, b}, {3}]]]
  ], {i, 1, 6, 1}]

Blockquote

Junho Lee
  • 5,155
  • 1
  • 15
  • 33
6

You can also use Mesh to show the second list in a single ListPlot3D as follows:

data = Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}];
(* using the same set-up as in Junho Lee's answer *) 

ListPlot3D[data, PlotStyle->Opacity[0.6], Mesh->{20, {1, {2, Directive[{Thick, Red}]}, 3, 4, 5}}]

enter image description here

Multiple 2D slices:

ListPlot3D[data, PlotStyle -> Opacity[0.6], 
 Mesh -> {20, {1, {2, Directive[{Thick, Red}]}, 3, {4, Directive[{Thick, Blue}]}, 5}}]

enter image description here

Multiple 2D slices in different directions:

ListPlot3D[data, PlotStyle -> Opacity[0.6],
 Mesh -> {Range[0, 6,  1/4] /. {3 -> {3, Directive[{Thick, Orange , Dashed}]},
                        5 -> {5, Directive[{Thick, Purple , DotDashed}]}}, 
         {1, {2, Directive[{Thick, Red}]}, 3, {4, Directive[{Thick, Blue}]}, 5}}]

enter image description here

Dynamic@With[{c = Clock[{1, 6, .1}, 2]},
  ListPlot3D[data, PlotStyle -> Opacity[0.6],
   Mesh -> {Range[0, 6, 1/4], {{c, Directive[{Thick, Red}]}}}]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896