0
$\begingroup$

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

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]

code for 3d plot

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ Sep 30, 2020 at 15:12

1 Answer 1

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

k1 = ListLinePlot[j1]

enter image description here

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}]]

enter image description here

Clear["Global`*"]

EDIT: Using your data

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

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

file2 = Import[
   "/Users/roberthanlon/Downloads/p1.ifs0_positive_oldc_chargecode"];

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"}]

enter image description here

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – krishna
    Sep 30, 2020 at 20:05
  • $\begingroup$ We cannot tell you exactly what to do since you did not provide us with the data or an appropriate subset of the data. $\endgroup$
    – Bob Hanlon
    Sep 30, 2020 at 20:08
  • $\begingroup$ 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. $\endgroup$
    – krishna
    Sep 30, 2020 at 20:27
  • $\begingroup$ Thank you very much Bob Hanlon,from the bottom of my heart. You resolved my big headache. $\endgroup$
    – krishna
    Oct 1, 2020 at 13:07

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.