# How to combine lineplot and 3dplot in mathematica having same axes?

I want to merge the 2dline plot to 3dplot. any help will be appreciated.

j1 = Transpose[{i8, i2}];
k1 = ListLinePlot[j1, AxesLabel -> {"x", "z"}, PlotStyle -> Red,
PlotRange -> {{500, 1500}, {0, 160}},
AxesStyle -> Thickness[0.004],
LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, Bold},
ImageSize -> Large];

s1 = Transpose[{p8, p1, p2}];
h2 = ListPointPlot3D[s1, AxesLabel -> {"x", "y", "z"},
PlotStyle -> Green,
PlotRange -> {{500, 1500}, {0., 0.5}, {0, 160}},
AxesStyle -> Thickness[0.004],
LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, Bold},
ImageSize -> Large];

Show[h2, k1]


• A 2D and 3D plot cannot be combined. Why not modify j1 to add whatever y value it corresponds to the s1 data. Use a wrapper to style the augmented j1 values with a different color. Sep 30, 2020 at 15:12

j1 = Table[{i, Sin[2^2 + i]}, {i, 0, 3, 0.05}];

k1 = ListLinePlot[j1]


Extract the line and convert it to 3D

y0 = 2;

line = Cases[k1, Line[pts_] :> Line[{#[[1]], y0, #[[2]]} & /@ pts],
Infinity][[1]];

s1 = Table[{i, j, Sin[j^2 + i]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}];


Combine the line with the ListPointPlot3D

Show[
ListPointPlot3D[s1],
Graphics3D[{Red, Thick, line}]]


Clear["Global*"]

file1 = Import["/Users/roberthanlon/Downloads/i1.xlsx"];

j1 = Sort@file1[[1, All, {8, 2}]];

file2 = Import[

s1 = file2[[All, {8, 1, 2}]];

Manipulate[
Show[
ListPointPlot3D[s1, AxesLabel -> {"x", "y", "z"},
PlotStyle -> Green,
PlotRange -> {{500, 1500}, {0., 0.5}, {0, 160}},
AxesStyle -> Thickness[0.004],
LabelStyle -> {FontSize -> 16, FontFamily -> "Times", Black, Bold},
ImageSize -> Medium],
Graphics3D[{Red, Thick, Line[{#[[1]], y0, #[[2]]} & /@ j1]}]],
{{y0, 0}, 0, 0.5, 0.01, Appearance -> "Labeled"}]
`

• Thanks, Bob. But both of my tables are totally different columns, though they have the same scale I can't repeat i in the second loop. Trying to get it. Sep 30, 2020 at 20:05
• We cannot tell you exactly what to do since you did not provide us with the data or an appropriate subset of the data. Sep 30, 2020 at 20:08
• I have no idea how to attach in mathematica. The files are on this link drive.google.com/drive/folders/… . p1 file 1,8 and 2nd columns are chosen and i1 file 2 and 8 columns are chosen. Thank you very much again. Sep 30, 2020 at 20:27
• Thank you very much Bob Hanlon,from the bottom of my heart. You resolved my big headache. Oct 1, 2020 at 13:07