0
$\begingroup$

We have two lists with plot: ( Because they are not very short we uploaded list1 and list2,here and here)

enter image description here

In some regions the values related to the z axis of list2 gets exceeding from the values related to the z axis of list1. We specified these regions with red color.

Main Question: Because we have data and not functions, we could not use ContourPlot to show these areas. How can we present these zones in a 2 dimensional plane.

Second Question: We exploited

Export["list1.txt", list1, "Table"];

and

read = Import["list1.txt", "Table"];

to save and read data. But in importing, we think Pi will not be imported in a suitable format. How can we import data which contain Pi as $\pi$?

$\endgroup$
  • 1
    $\begingroup$ read = ToExpression[Import["list1.txt", "Table"]]; works $\endgroup$ – Coolwater Dec 16 '17 at 16:03
5
$\begingroup$
lst1 = Import["/Users/roberthanlon/Downloads/list1.txt", "Table"] // 
   ToExpression;

lst2 = Import["/Users/roberthanlon/Downloads/list2.txt", "Table"] // 
   ToExpression;

The lists have the same length and the data lies on the same grid.

{Length[lst1] == Length[lst2], (Most /@ lst1) == (Most /@ lst2)}

(* {True, True} *)

The absolute differences of the z values are

lst3 = Append @@@ 
   Transpose[{Most /@ lst1, Abs[(Last /@ lst1) - (Last /@ lst2)]}];

Using ListContourPlot for the absolute differences

ListContourPlot[lst3,
 PlotLegends -> Automatic,
 ColorFunction -> "TemperatureMap"]

enter image description here

EDIT: Looking only at lst2 > lst1

lst4 = Append @@@ 
   Transpose[{Most /@ lst1, 
     Max[#, 0] & /@ ((Last /@ lst2) - (Last /@ lst1))}];

ListContourPlot[lst4, PlotLegends -> Automatic, 
 ColorFunction -> (Blend[{White, Red}, #] &)]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much, If we ignore Abs, I think the considered zones are more clear. It would be very desired if all differences (of two lists) get zero except when list2>list1, in this case, the color of all ListContourPlot zones will be the same except while list2>list1 $\endgroup$ – Inzo Babaria Dec 16 '17 at 18:32
  • $\begingroup$ list3 = Table[{i, j, 0}, {i, 0, 4 \[Pi], \[Pi]/16}, {j, collection}]; list3new = Flatten[list3, 1];Do[ If[list1[[i]][[3]] - list2[[i]][[3]] < 0, list3new[[i]][[3]] = list2[[i]][[3]] - list1[[i]][[3]]] , {i, 1, Length@list2}] $\endgroup$ – Inzo Babaria Dec 16 '17 at 18:58
  • $\begingroup$ the above code approximately does the goal but in an unprofessional way. Your guidance is more professional than mine. Thanks a bunch!! $\endgroup$ – Inzo Babaria Dec 16 '17 at 19:05

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.