-2
$\begingroup$

I can display a 3D surface with z-axis {z,-100, 15000}: Plot3D[n2U[v, n], {v, -100.0, 20.0}, {n, 0.0, 1.0}].

I can plot a 3D line: ListLinePlot3D[mydata] which has z-axis {z, -100, 12000}. The line happens to lie on the 3D surface but that is not relevant to the question:

How can I display the 3D surface and the 3D line in the same 3D cartesian coordinate system?

$\endgroup$
5
  • 2
    $\begingroup$ Can you, please, provide some minimal working code for the Plot3D and the ListLinePlot3D? $\endgroup$
    – bmf
    Jan 9, 2023 at 5:12
  • $\begingroup$ What does Heading have to do with anything?? $\endgroup$ Jan 9, 2023 at 6:57
  • $\begingroup$ Across the top of the screen you should see "Search on Mathematica..." I typed "draw line on plot" in that box, but did not include those quotes, and found several likely answers in the first ten results. From that I used one of those answers Show[Plot3D[x+y,{x,-1,1},{y,-1,1},PlotStyle-> Green], Graphics3D[{Red,Line[{{-1,-1,-2},{1,1,2}}]}]] Adjust that as needed. $\endgroup$
    – Bill
    Jan 9, 2023 at 7:31
  • $\begingroup$ Similar to 20565. $\endgroup$
    – Syed
    Jan 9, 2023 at 7:53
  • $\begingroup$ Thank you, Bill. This "Show"s me how to proceed (pun intended). $\endgroup$
    – Peter R
    Jan 10, 2023 at 5:18

1 Answer 1

2
$\begingroup$

You may use "Show" for this:

line = ListLinePlot3D[Table[{x, 0, x^2}, {x, -1, 1, 0.1}], 
   PlotStyle -> {Red, Thickness[0.01]}];
Show[{line,
  Plot3D[{x^2 + y^2}, {x, -1, 1}, {y, -1, 1}]
  }]

enter image description here

$\endgroup$

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