7
$\begingroup$

I'm trying to put together several different 2D plots in a 3D graphics to create a figure which would be like the one below (taken from https://aip.scitation.org/doi/10.1063/1.4998724)enter image description here

However my plots are not contour plot like on this example. My plots looks like the one below where I used ListPlot to draw the different curves.

![enter image description here

I tried with ListPlot3D and ListPointPlot3D but with these two functions I didn't succeed to join the points to form the different curves like on the figure above and without joining them between two different plots.

Edit:

Here are the data that I used to plot the example:

{{{70,-3.28540334263527},{71,-3.27432278919873},{72,-3.26369368174397},{73,-3.25350695026436},{74,-3.24375348226142},{75,-3.23442415473233},{76,-3.22550986251597},{77,-3.21700154312006},{78,-3.20889019829817},{79,-3.20116691256438},{80,-3.19382286878205},{81,-3.18684936107068},{82,-3.18023780506416},{83,-3.17397974576673},{84,-3.16806686299172},{85,-3.16249097460629},{86,-3.15724403754810},{87,-3.15231814685867},{88,-3.14770553296841},{89,-3.14339855987631},{90,-3.13937707615996},{91,-3.14339855977977},{92,-3.14770553286154},{93,-3.15231814673735},{94,-3.15724403741609},{95,-3.16249097446346},{96,-3.16806686283783},{97,-3.17397974559794},{98,-3.18023780488394},{99,-3.18684936087512},{100,-3.19382286857901},{101,-3.20116691234546},{102,-3.20889019806751},{103,-3.21700154287390},{104,-3.22550986225745},{105,-3.23442415445781},{106,-3.24375348197424},{107,-3.25350694996440},{108,-3.26369368142447},{109,-3.27432278886608},{110,-3.28540334228624}},{{70,-3.11063325021876},{71,-3.11022689504167},{72,-3.10996312550354},{73,-3.10985209796379},{74,-3.10990342145198},{75,-3.11012622440815},{76,-3.11052921650446},{77,-3.11112074579084},{78,-3.11190885158078},{79,-3.11290131322705},{80,-3.11410569523733},{81,-3.11552938883352},{82,-3.11717965019974},{83,-3.11906363569176},{84,-3.12118843406927},{85,-3.12356109603436},{86,-3.12618866107205},{87,-3.12907818179438},{88,-3.13223674550530},{89,-3.13567149057300},{90,Indeterminate},{91,-3.13567149064917},{92,-3.13223674557155},{93,-3.12907818184708},{94,-3.12618866109730},{95,-3.12356109606813},{96,-3.12118843409384},{97,-3.11906363570343},{98,-3.11717965020261},{99,-3.11552938882398},{100,-3.11410569522326},{101,-3.11290131320091},{102,-3.11190885154672},{103,-3.11112074575196},{104,-3.11052921645137},{105,-3.11012622434405},{106,-3.10990342138101},{107,-3.10985209788629},{108,-3.10996312541193},{109,-3.11022689494425},{110,-3.11063325011183}},{{70,-3.09890860461704},{71,-3.09812297332464},{72,-3.09746808563295},{73,-3.09695377137550},{74,-3.09658930768585},{75,-3.09638348624581},{76,-3.09634467572243},{77,-3.09648087964960},{78,-3.09679979012982},{79,-3.09730883765275},{80,-3.09801523725152},{81,-3.09892603134186},{82,-3.10004812935466},{83,-3.10138834448757},{84,-3.10295342763722},{85,-3.10475009880658},{86,-3.10678507600178},{87,-3.10906510187972},{88,-3.11159696815476},{89,-3.11438753791437},{90,-3.11744376588204},{91,-3.11438753797592},{92,-3.11159696820685},{93,-3.10906510191859},{94,-3.10678507603137},{95,-3.10475009882735},{96,-3.10295342764910},{97,-3.10138834448689},{98,-3.10004812934564},{99,-3.09892603132066},{100,-3.09801523722618},{101,-3.09730883761564},{102,-3.09679979008510},{103,-3.09648087959366},{104,-3.09634467565940},{105,-3.09638348617204},{106,-3.09658930760547},{107,-3.09695377128884},{108,-3.09746808553250},{109,-3.09812297321862},{110,-3.09890860450176}}}

Does anyone know how to do this?

Thank you in advance for your response.


Thank you everyone for all the answers! I'll try each of your method and see which one fits better for my plots.

$\endgroup$
1
  • $\begingroup$ Please provide sample data for a minimal example. $\endgroup$
    – Bob Hanlon
    Mar 31, 2021 at 15:49

4 Answers 4

5
$\begingroup$
lp = ListPlot[data, PlotStyle -> ColorData[97] /@ {4, 1, 2}, 
  Frame -> True]

enter image description here

We can define a function that transforms the graphics primitives of lp to the desired 3D primitives and use these primitives with Graphics3D:

ClearAll[translations]
translations[levels : {__} : {1}, dir : "X" | "Y" | "Z" : "X", h_: (0 &)] := 
  ReplaceAll[Point[x_] :> Module[{d = dir /. Thread[{"X", "Y", "Z"} -> Range[3]]}, 
   {Point @ #, Line @ #} & /@ Table[Insert[#, i + h @@ #, d] & /@ x, {i, levels}]]];

Examples:

Make 3 copies placed at x = 1, x = 2 and x = 3:

Graphics3D[translations[Range[3]] @ lp[[1]], 
  BoxRatios -> {2, 1, 1}, ImageSize -> Large, Axes -> True]

enter image description here

Make 3 copies at y = 1, y = 2 and y = 3:

Graphics3D[translations[Range[3], "Y"] @ lp[[1]], 
 BoxRatios -> {1, 2, 1}, ImageSize -> Large, Axes -> True]

enter image description here

Make 3 copies at z = 1, z = 2 and z = 3:

Graphics3D[translations[Range[3], "Z"] @ lp[[1]], 
 BoxRatios -> {1, 1, 2}, ImageSize -> Large, Axes -> True]

enter image description here

5 copies at random x positions between 1 and 100:

SeedRandom[1]
Graphics3D[translations[RandomSample[Range[100], 5]]@lp[[1]], 
 BoxRatios -> {2, 1, 1}, ImageSize -> Large, Axes -> True]

enter image description here

Perturb x-coordinates by Sin[y Pi /40 + z 100 Pi/3]/10:

Graphics3D[{translations[Range[3], "X", .1 Sin[# Pi /40 + #2 100 Pi/3] &] @ lp[[1]], 
  Text[Style["☺", 46], {#, 90, -3.10}] & /@ {1, 2, 3}},
  BoxRatios -> {2, 1, 1}, ImageSize -> Large, Axes -> True]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you for the answer! This is really helpful! $\endgroup$
    – AntoineM
    Apr 2, 2021 at 12:02
5
$\begingroup$

You could duplicate the points with values assigned on a third axis. For example using row values {1,2,3,4,5,6}:

rows = Range[6];
data2 = Table[PadLeft[lst, {Length[lst], 3}, r], {r, rows}, {lst, data}];
ListPointPlot3D[Flatten[data2, 1], PlotStyle -> {Red, Lighter@Blue, Orange}]

enter image description here

$\endgroup$
4
$\begingroup$
data = {{{70, -3.28540334263527}, {71, -3.27432278919873}, {72, \
-3.26369368174397}, {73, -3.25350695026436}, {74, -3.24375348226142}, \
{75, -3.23442415473233}, {76, -3.22550986251597}, {77, \
-3.21700154312006}, {78, -3.20889019829817}, {79, -3.20116691256438}, \
{80, -3.19382286878205}, {81, -3.18684936107068}, {82, \
-3.18023780506416}, {83, -3.17397974576673}, {84, -3.16806686299172}, \
{85, -3.16249097460629}, {86, -3.15724403754810}, {87, \
-3.15231814685867}, {88, -3.14770553296841}, {89, -3.14339855987631}, \
{90, -3.13937707615996}, {91, -3.14339855977977}, {92, \
-3.14770553286154}, {93, -3.15231814673735}, {94, -3.15724403741609}, \
{95, -3.16249097446346}, {96, -3.16806686283783}, {97, \
-3.17397974559794}, {98, -3.18023780488394}, {99, -3.18684936087512}, \
{100, -3.19382286857901}, {101, -3.20116691234546}, {102, \
-3.20889019806751}, {103, -3.21700154287390}, {104, \
-3.22550986225745}, {105, -3.23442415445781}, {106, \
-3.24375348197424}, {107, -3.25350694996440}, {108, \
-3.26369368142447}, {109, -3.27432278886608}, {110, \
-3.28540334228624}}, {{70, -3.11063325021876}, {71, \
-3.11022689504167}, {72, -3.10996312550354}, {73, -3.10985209796379}, \
{74, -3.10990342145198}, {75, -3.11012622440815}, {76, \
-3.11052921650446}, {77, -3.11112074579084}, {78, -3.11190885158078}, \
{79, -3.11290131322705}, {80, -3.11410569523733}, {81, \
-3.11552938883352}, {82, -3.11717965019974}, {83, -3.11906363569176}, \
{84, -3.12118843406927}, {85, -3.12356109603436}, {86, \
-3.12618866107205}, {87, -3.12907818179438}, {88, -3.13223674550530}, \
{89, -3.13567149057300}, {90, 
     Indeterminate}, {91, -3.13567149064917}, {92, \
-3.13223674557155}, {93, -3.12907818184708}, {94, -3.12618866109730}, \
{95, -3.12356109606813}, {96, -3.12118843409384}, {97, \
-3.11906363570343}, {98, -3.11717965020261}, {99, -3.11552938882398}, \
{100, -3.11410569522326}, {101, -3.11290131320091}, {102, \
-3.11190885154672}, {103, -3.11112074575196}, {104, \
-3.11052921645137}, {105, -3.11012622434405}, {106, \
-3.10990342138101}, {107, -3.10985209788629}, {108, \
-3.10996312541193}, {109, -3.11022689494425}, {110, \
-3.11063325011183}}, {{70, -3.09890860461704}, {71, \
-3.09812297332464}, {72, -3.09746808563295}, {73, -3.09695377137550}, \
{74, -3.09658930768585}, {75, -3.09638348624581}, {76, \
-3.09634467572243}, {77, -3.09648087964960}, {78, -3.09679979012982}, \
{79, -3.09730883765275}, {80, -3.09801523725152}, {81, \
-3.09892603134186}, {82, -3.10004812935466}, {83, -3.10138834448757}, \
{84, -3.10295342763722}, {85, -3.10475009880658}, {86, \
-3.10678507600178}, {87, -3.10906510187972}, {88, -3.11159696815476}, \
{89, -3.11438753791437}, {90, -3.11744376588204}, {91, \
-3.11438753797592}, {92, -3.11159696820685}, {93, -3.10906510191859}, \
{94, -3.10678507603137}, {95, -3.10475009882735}, {96, \
-3.10295342764910}, {97, -3.10138834448689}, {98, -3.10004812934564}, \
{99, -3.09892603132066}, {100, -3.09801523722618}, {101, \
-3.09730883761564}, {102, -3.09679979008510}, {103, \
-3.09648087959366}, {104, -3.09634467565940}, {105, \
-3.09638348617204}, {106, -3.09658930760547}, {107, \
-3.09695377128884}, {108, -3.09746808553250}, {109, \
-3.09812297321862}, {110, -3.09890860450176}}};

Convert your data to 3D

data3D = MapIndexed[Insert[#1, First@#2, 2] &, 
   data /. {_, Indeterminate} :> Nothing, {2}];

Show[
 ListPointPlot3D[data3D],
 Graphics3D[Line /@ data3D],
 PlotRange -> Full,
 BoxRatios -> {1, 1, 1}]

enter image description here

$\endgroup$
3
$\begingroup$

Manually crafting the 3d data is a good approach and may be acceptable. Another approach is to use the ListLinePlots themselves as textures for 3d polygons:

dat=yourlist&/@Range@6;
Show@@Join[
  {Plot3D[0,{x,1,6},{y,0,1},
  PlotRange->{{1,6},{0,1},{0,1}},RegionFunction->False,
  Ticks->Automatic,Lighting->{{"Ambient",White}},FaceGrids->All]},
  
  Graphics3D[{EdgeForm@None,Texture@Image@
    ListLinePlot[dat[[#]],PlotMarkers->
    {"\[FilledCircle]", "\[FilledSquare]","\[FilledDiamond]"},
    PlotStyle->{Red,Blue,Orange},Ticks->None],
    Polygon[{{#,0,0},{#,1,0},{#,1,1},{#,0,1}},
    VertexTextureCoordinates->{{0,0},{1,0},{1,1},{0,1}}]}]&/@
  Range@6,{BoxRatios->Automatic}]

The first Plot3D is a dummy plot (RegionFunction->False; it plots nothing) to get customizable FaceGrids, Ticks, Labels etc. Lighting is important because the default lighting looks weird on the images of the plots. A big drawback is the plots aren't transparent, though I think this can be achieved. Perhaps this approach is useful if your plots are hard to reproduce by hand with simple 3d lines or have complicated styles.

plot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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