0
$\begingroup$

I got the following table of my data:Amplitudes at each site for different t1-values and energy eigenvalues]1

and I am trying to plot the amplitudes at each site for every t1-value such that a 3Dplot is created in terms of {x=numberofsite,y=t1-value,z={amplituevalue1,amplituevalue2,amplituevalue3,amplituevalue4}} having therefore a line when linking all the amplitudevalues. Nevertheless, I want each line to be colored according to its energy value. Can someone help me do this? For now, what I have achieved is to make the two dplots and stack them together using insets inside a Graphics 3D, but the y-axis with each t1 value is missing, and it does not work very well.

Here is an example of this method with only the two first t1-values {-3,-2}:

     (*Amplitudes at each site and respective eigenvalues*)
    eigenvectors = {{{0.20275444087384661`, 0.29724555912615347`, 
         0.29724555912615347`, 
         0.20275444087384661`}, {0.20275444087384661`, 
         0.29724555912615347`, 0.29724555912615347`, 
         0.20275444087384661`}, {0.2972455591261534`, 
         0.20275444087384664`, 0.20275444087384664`, 
         0.29724555912615336`}, {0.2972455591261534`, 
         0.20275444087384664`, 0.20275444087384664`, 
         0.29724555912615336`}}, {{0.16161165235168157`, 
         0.3383883476483185`, 0.3383883476483185`, 
         0.16161165235168157`}, {0.16161165235168157`, 
         0.3383883476483185`, 0.3383883476483185`, 
         0.16161165235168157`}, {0.33838834764831843`, 
         0.16161165235168157`, 0.16161165235168157`, 
         0.33838834764831843`}, {0.33838834764831843`, 
         0.16161165235168157`, 0.16161165235168157`, 
         0.33838834764831843`}}};
    eigenvalues = {{-3.1457513110645907`, 
        3.1457513110645907`, -2.1457513110645907`, 
        2.1457513110645907`}, {-1.9142135623730951`, 
        1.9142135623730951`, -0.9142135623730951`, 0.9142135623730951`}};
    
    amplitudes[i_] := Transpose[eigenvectors[[i]]];
    
    (*Colouring the amplitudes according to respective eigenvalues*)
    colors[i_] := ColorData["Rainbow"] /@ Rescale[eigenvalues[[i]]];
    
    (*2D Plots of the amplitudes with colored lines according to eigenvalues*)
    plot2d = Table[
      ListLinePlot[Transpose@amplitudes[i], PlotStyle -> colors[i], 
       Frame -> True, 
       PlotLegends -> BarLegend[{"Rainbow", MinMax[eigenvalues]}, LegendLabel -> "Eigenvalues"]], {i, 1, 2}]

2Dplots

    (*3DPlot considering the previous 2dplots stacked together and with the respective coloured lines*)
    Show[Graphics3D[{Inset[plot2d[[1]], {0, 0, 0}], 
       Inset[plot2d[[2]], {0, 0, 1}]}, Boxed -> False, 
      ViewPoint -> {2, -2, 2}], PlotRange -> {{-1, 1}, {-1, 1}, {0, 1}}, 
[PlotLabel: "Combined 3D Plot"] 

3DPlot

I tried this method 4, but it won't work. I also tried reorganizing the original data through {x,y,z}, but the most I could do was the following:

    xyzQData = {{{{-3, 1, 0.202754, -3.14575}, {-3, 1, 
      0.202754, -3.14575}, {-3, 1, 0.297246, -3.14575}, {-3, 1, 
      0.297246, -3.14575}}, {{-3, 2, 0.297246, 3.14575}, {-3, 2, 
      0.297246, 3.14575}, {-3, 2, 0.202754, 3.14575}, {-3, 2, 
      0.202754, 3.14575}}, {{-3, 3, 0.297246, -2.14575}, {-3, 3, 
      0.297246, -2.14575}, {-3, 3, 0.202754, -2.14575}, {-3, 3, 
      0.202754, -2.14575}}, {{-3, 4, 0.202754, 2.14575}, {-3, 4, 
      0.202754, 2.14575}, {-3, 4, 0.297246, 2.14575}, {-3, 4, 
      0.297246, 2.14575}}}, {{{-2, 1, 0.161612, -1.91421}, {-2, 1, 
      0.161612, -1.91421}, {-2, 1, 0.338388, -1.91421}, {-2, 1, 
      0.338388, -1.91421}}, {{-2, 2, 0.338388, 1.91421}, {-2, 2, 
      0.338388, 1.91421}, {-2, 2, 0.161612, 1.91421}, {-2, 2, 
      0.161612, 1.91421}}, {{-2, 3, 0.338388, -0.914214}, {-2, 3, 
      0.338388, -0.914214}, {-2, 3, 0.161612, -0.914214}, {-2, 3, 
      0.161612, -0.914214}}, {{-2, 4, 0.161612, 0.914214}, {-2, 4, 
      0.161612, 0.914214}, {-2, 4, 0.338388, 0.914214}, {-2, 4, 
      0.338388, 0.914214}}}};

xyzData = xyzQData[[All, All, All, 1; 3]];

zColors = xyzQData[[All, All, All, 4]];

colorFunction[z_, eigenvaluesList_] := 
 ColorData["Rainbow"][Rescale[z, MinMax[eigenvaluesList]]];

plots = Table[
   ListLinePlot3D[Transpose@xyzData[[i]], 
    ColorFunction -> (colorFunction[Flatten[zColors], zColors] &), 
    PlotStyle -> AbsoluteThickness[2], BoxRatios -> {1, 1, 1}, 
    Lighting -> "Neutral", AxesLabel -> {"X", "Y", "Z"}, 
    PlotLegends -> 
     BarLegend[{"Rainbow", MinMax[Flatten[zColors]]}, 
      LegendLabel -> "Eigenvalues"; ViewPoint -> {2.5, 1, 2.5}; {i, 
    Length[xyzData]}];


Show[plots, PlotRange -> All]

3DPlot using XYZQvalues

where the amplitude lines are not correctly colored, like in the 2D plots.

$\endgroup$
0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.