0
$\begingroup$

I have the calculated data for an interaction potential. My variables are distances (48 values) and angles(15 values) and my energy data is a 2d matrix of 48 x 15 values. How do i plot the energy as a contour? I am not sure how to assign it to a variable or import it as an array(Also it is a huge amount of data). I tried using Table and plotted using ListContourPlot, but i get the error "it is not a valid array". Is there any way to do this?

This is the smaller version of my data:

In[120]:= En = Table[Import["D:\pes\en.txt"]]

Out[120]= "0.00170451   0.00121435  0.00064304
0.00109223  0.0007588   0.00037006
0.00066955  0.00044523  0.00018417
0.00038108  0.00023235  6.00379142E-05"

In[121]:= Dis = List[6.05, 6.2, 6.35, 6.5]

Out[121]= {6.05, 6.2, 6.35, 6.5}

In[122]:= An = List[8.8877, 20.4014, 31.9828]

Out[122]= {8.8877, 20.4014, 31.9828}



In[124]:= ListContourPlot[{Dis, An, En}, InterpolationOrder -> 0.1]

During evaluation of In[124]:= ListContourPlot::arrayerr: {{6.05,6.2,6.35,6.5},{8.8877,20.4014,31.9828},0.00170451  0.00121435  0.00064304
0.00109223  0.0007588   0.00037006
0.00066955  0.00044523  0.00018417
0.00038108  0.00023235  6.00379142E-05} must be a valid array.

Out[124]= ListContourPlot[{{6.05, 6.2, 6.35, 6.5}, {8.8877, 20.4014, 
   31.9828}, "0.00170451    0.00121435  0.00064304
  0.00109223    0.0007588   0.00037006
  0.00066955    0.00044523  0.00018417
  0.00038108    0.00023235  6.00379142E-05"}, InterpolationOrder -> 0.1]
$\endgroup$
3
  • $\begingroup$ We can't know what's wrong without seeing the data. If it involves a lot of data, try to reproduce the problem with a smaller amount of data that you can post here (or so that you can post code that generates the sample data). $\endgroup$
    – C. E.
    Oct 23, 2020 at 7:44
  • $\begingroup$ Yes, i have edited my question. $\endgroup$ Oct 23, 2020 at 9:17
  • 2
    $\begingroup$ The first line import the numbers are a string. Try En = Import["D:\pes\en.txt", "Table"] and you should get a matrix instead. $\endgroup$
    – C. E.
    Oct 23, 2020 at 10:28

2 Answers 2

2
$\begingroup$

Here is your example3. But it is not clear to which value of "En" which distance and angle to assign. I simply made an assumption. If I am wrong, you may have to swap d2 and d3 in: Flatten[Outer[List, d2, d3], 1].

d1 = ImportString[
   "0.00170451   0.00121435  0.00064304 0.00109223  0.0007588   \
0.00037006 0.00066955  0.00044523  0.00018417 0.00038108  0.00023235  \
6.00379142E-05", "Table"][[1]];
d2 = List[6.05, 6.2, 6.35, 6.5];
d3 = List[8.8877, 20.4014, 31.9828];
d4 = Flatten[Outer[List, d2, d3], 1];
d5 = MapThread[Append, {d4, d1}];
ListContourPlot[d5]

enter image description here

$\endgroup$
0
0
$\begingroup$

Thank you so much, I got the proper form of the data to plot. This is the plot i get

ListContourPlot[Pes, ContourLabels -> All, PlotLegends -> Automatic, 
ColorFunctionScaling -> False, PlotRange -> {{0, 180}, {6, 11}}, 
ColorFunction -> 
Function[{Enn}, ColorData[{"BlueGreenYellow", {-35, 150}}][Enn]]]

But most of my points don't seem to be distinguished. How do i rescale the color function to graph all the points?

enter image description here

$\endgroup$

Your Answer

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

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