Plotting Contour

I am trying to plot co Contour Plots for Tempereature data given in 2D Space (X,Z) in Mathematica. The data is read from CSV file. I have a code that I thinks should work fine, but it plots something outrages. Please help to correct my code. It is below

dataContour = Import["DataToPlot 90.csv"];
len = Length[dataContour];

TemeratureChange = dataContour[[2 ;; len, 11]];
Zm = dataContour[[2 ;; len, 3]];
Xm = dataContour[[2 ;; len, 9]];
data1 = Table[{ TemeratureChange[[i]], Xm[[i]], Zm[[i]]}, {i, 1,
len - 1}];
ListContourPlot[Transpose[data1], PlotLegends -> Automatic,
Contours -> 30, ColorFunction -> Hue,
AxesLabel -> {"x axis", "y axis"}, AxesLabel -> {"x", "y"},
PlotLabel -> "Temperature Change (oC)"]

This code plots this I am expecting to see contour plot similar to this . The last picture was ploted in Grapher.

What is wring with Mathematica code above? Thank you.

Best wishes, Maria

• Have you looked at your data? What numbers correspond with the vertical black lines? – GerardF123 Nov 8 '18 at 15:42
• Without seeing the data, I'd expect that you want {Xm[[i]], Zm[[i]], TemeratureChange[[i]]} – the values corresponding to contours is #3 in the data. But the use of Transpose is also confusing to me, since it looks like data1 should already be the list of {x, y, z} triples the ListContourPlot wants. – Brett Champion Nov 8 '18 at 15:52
• Temperature is changing {from -3.8 to 2.6}. My X coordinate is changing within the range {-98 to 98 }. My Y coordinate is changing within the range {-5 to 235 }. I don't know exactly what black lines are – Mary Madyarova Nov 8 '18 at 15:54
• @MaryMadyarova I think this will help: mathematica.stackexchange.com/help/merging-accounts – Kuba Nov 8 '18 at 17:02
• Once you do this please take a look at asking guidelines. – Kuba Nov 9 '18 at 7:33

It looks like you're doing something like

ListContourPlot[Transpose@
Flatten[Table[{Sin[i + j^2], i, j}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}], 1]] when you really want

ListContourPlot[Flatten[Table[{i, j, Sin[i + j^2]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}], 1]] With the transposed data, ListContourPlot treats it as an array of heights instead of {x, y, z} triples.

(You can ignore the Flatten in my code above, it's just there to get a list of triples instead of an 2D array of them.)

So I think what you're really looking for is

data1 = Table[{Xm[[i]], Zm[[i]], TemeratureChange[[i]]}, {i, 1, len - 1}];
ListContourPlot[data1, <options>]
• Brett Champion, I have changed the last two lines how you proposed and it looks better now. data1 = Table[{ Xm[[i]], Zm[[i]], TemeratureChange[[i]]}, {i, 1, len - 1}]; ListContourPlot[data1, PlotLegends -> Automatic, ColorFunction -> Hue, AxesLabel -> {"x axis", "y axis"}, AxesLabel -> {"x", "y"}, PlotLabel -> "Temperature Change (oC)"] Do you know why I have this white color in the middle of the plot and why axis labels {"x", "y"} are not on the plot? ![enter image description here](i.stack.imgur.com/8BHgV.png) – Mary Madyarova Nov 8 '18 at 16:05
• Brett Champion, It works. Thank you so much! The important question now is: "Is there a way to specify colorbar on the legend from -4 to 1 and have colors from red to blue, respectively?" Also, how to reverse an Yaxis and specify X axis from 0 to 28. – Mary Madyarova Nov 8 '18 at 17:02
• Here's a dump of things to look up: (1) PlotLegends and BarLegend; (2) ColorFunction, ColorFunctionScaling, Blend, and ColorData; (3) ScalingFunctions; (4) PlotRange. Combination of this site, subsections of the ListContourPlot docs, and individual docs pages (eg. ref/BarLegend) should be useful. – Brett Champion Nov 8 '18 at 20:33
• I have modified the code slightly. It is showing me nice results. But I am having hard time inversing the Y axis - I need Y ahis to change from 0 (top) to 180 (bottom). Brett Champion, would you know how to do it? Why ScalingFunction is not working? Thank you. SetDirectory["G:\\FGCI Staff\\Madyarova\\Mathematica\\Contour Plots"]; dataContour = Import["DataToPlot 90.csv"]; len = Length[dataContour]; legendwidth = 500; plotheights = 500; TemeratureChange = dataContour[[2 ;; len, 11]]; Zm = dataContour[[2 ;; len, 3]]; Xm = dataContour[[2 ;; len, 9]]; data1 = Table[{ Xm[[i]], Zm[[i]], TemeratureCh – Mary Madyarova Nov 8 '18 at 23:53
• @MaryMadyarova Please stop posting follow-up questions as answers. If you follow the link I have given in the comment below the question you will be able to merge your accounts and post comments under Brett's answer. – Kuba Nov 9 '18 at 7:30

protected by Kuba♦Nov 9 '18 at 7:33

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?