2
$\begingroup$

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?

$\endgroup$
1

2 Answers 2

7
$\begingroup$

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

$\endgroup$
6
$\begingroup$

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

$\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.