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


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$?

  • 1
    $\begingroup$ read = ToExpression[Import["list1.txt", "Table"]]; works $\endgroup$
    – Coolwater
    Commented Dec 16, 2017 at 16:03

1 Answer 1

lst1 = Import["/Users/roberthanlon/Downloads/list1.txt", "Table"] // 

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

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

 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

  • $\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$ Commented Dec 16, 2017 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$ Commented Dec 16, 2017 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$ Commented Dec 16, 2017 at 19:05

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.