# Is Mathematica capable of producing 2d contour plots from .txt files with the contour levels being in logarithmic scale?

I have a text file that contains five columns of data in which columns 1 and 2 correspond to projected distance along dimension 1 and 2 from the center of the dark halo and then columns 3, 4 and 5 are values of the neutral hydrogen column density in projections 0 "z", 1 "x" and 2 "y" respectively. I would like to transform this .txt table into actual 2d maps in which the color strength of each pixel would correspond to the magnitude of the function in that pixel. This means that I would have three planes xy, yz and xz in which each pixel is filled with a color.

My values for columns 3,4 and 5 are mostly zero with few of them on the order of $10^{14}$ to $10^{21}$. I am interested in having three contour levels (less than $10^{17}$, between $10^{17}$ and $10^{20.3}$ and larger than $10^{20.3}$). Let's say if the function value is smaller than $10^{17}$, the color should be LightRed, if the function value is between $10^{17}$ and $10^{20.3}$, the color should be Red, and if the function value is larger than $10^{20.3}$, the color should be DarkRed. In other words, my 2d map is in fact a set of 3 contour plots that are produced out of .txt table. (Here is the link of a portion of my data: MyData)

Is there anyway to translate this into the maps by a color bar and apply it to the maps?

Based on the examples shown in ListContourPlot, I could not find something similar to my case. But, here is what I have for the three maps (thanks to Conor Consett for solving the original problem of importing a .txt file into mathematica notebook) including the modifications I made in the original code (considering ALL data and not the abridged version uploaded here):

datam10q =
Import["/Users/U of A/Desktop/covering_fractions/m10q.txt", "Table"]
xy10q = datam10q[[All, {1, 2, 3}]];
yz10q = datam10q[[All, {1, 2, 4}]];
xz10q = datam10q[[All, {1, 2, 5}]];
{ListContourPlot[xy10q,
Contours -> {{10^14, Thick}, {10^15.5, Thick}, {10^17,
Thick}, {10^20.3, Thick}},
ContourShading -> {Yellow, Orange, Red, Brown, Black},
ContourStyle -> None, InterpolationOrder -> 5,
BoundaryStyle -> Black, PerformanceGoal -> "Quality"],
ListContourPlot[yz10q,
Contours -> {{10^14, Thick}, {10^15.5, Thick}, {10^17,
Thick}, {10^20.3, Thick}},
ContourShading -> {Yellow, Orange, Red, Brown, Black},
ContourStyle -> None, InterpolationOrder -> 5,
BoundaryStyle -> Black, PerformanceGoal -> "Quality"],
ListContourPlot[xz10q,
Contours -> {{10^14, Thick}, {10^15.5, Thick}, {10^17,
Thick}, {10^20.3, Thick}},
ContourShading -> {Yellow, Orange, Red, Brown, Black},
ContourStyle -> None, InterpolationOrder -> 5,
BoundaryStyle -> Black, PerformanceGoal -> "Quality"]}


• I was getting disappointed with Mathematica and am looking for some python codes right now. Aug 18, 2016 at 5:19
• Have you had a look at something like this elementary introduction to mathematica. Investing some time to learn a few basics once is probably more efficient in the long run than "programming by copying/pasting code snippets together" Aug 18, 2016 at 5:27
• I do some things in mathematica like plotting and numerical calculations but have never had something like reading a file into mathematica and analysing them. When I see something like this, I stress out. Even though I post my questions, I do continue searching and researching in the hope that answers will narrow down my viewing point. I just know little bit of mathematica, python and Root but not expert in anyone of them. But, you are right. Aug 18, 2016 at 5:36
• Hi Conor, thanks for asking. The file was huge ~1,000,000 lines. But I manage to cut it off so that it can be uploaded in the website you gave me. Here it is. Just look into the text of the original post where it says ((Here is the link of a portion of my data: MyData)). I hope it may help me understand the issues, Aug 19, 2016 at 21:07

I would approach this by experimenting with a tiny version of the problem.

Here is a 5 column .txt file I made: http://pastebin.com/wCPxdvQB

Download it and Import it into your session with:

data = Import["/Users/johncosnett/Downloads/xy123data.txt", "Table"]

xy = data[[All, {1, 2, 3}]];
yz = data[[All, {1, 2, 4}]];
xz = data[[All, {1, 2, 5}]];

{ListContourPlot[xy, PlotTheme -> {"Monochrome", Red}],
ListContourPlot[yz, PlotTheme -> {"Monochrome", Red}],
ListContourPlot[xy, PlotTheme -> {"Monochrome", Red}]}


• Will let you know if I have any problem. Again thanks for your concerns. I am not that good in mathematica programming and just recently learned basic python. But, this looks promising. Aug 18, 2016 at 5:22
• One question: PlotTheme option is not recognized by my Mathematica 8.0 version. Is there any command to introduce it to the notebook? The problem: My values for columns 3,4 and 5 are mostly zero with few of them on the order of $10^{14}$ to $10^{21}$. Without introducing logarithmic scale I cannot see the pattern. I am interested in having three contour levels (less than $10^{17}$, between $10^{17}$ and $10^{20}$ and larger than $10^{20}$). Is there anyway to translate this into the maps by a color bar and apply it to the maps? Aug 18, 2016 at 19:21
• It seems PlotTheme is new in Mathematica10. Right? Aug 18, 2016 at 20:57
• I modified it slightly but it doesn't seem my Mathematica 8 is accepting PlotTheme. I tried to replace it with Contours option defining the ranges in which I am interested. But that also doesn't work. Thanks, Aug 19, 2016 at 3:08
• Hi Conor, just a silly question: My original question was answered correctly. Should I reformulate the question into a new one since I am stuck with new concerns or should I just leave it as it is until a new response is given? I was told that since an answer has been accepted already, no one is going to read this post again and I am going to lose that chance. Aug 22, 2016 at 18:38

(Not an answer, just an extended comment.)

Your dataset contains a lot of zeros in the $z$-coordinate, so it isn't exactly clear what you mean by logarithmic plot. Assuming that zero values must be simply ignored, we can log-transform the data:

data = Import["http://pastebin.com/raw/6Tj9LHvH", "Table"];
xy10q = DeleteCases[data[[All, {1, 2, 3}]], {_, _, 0.}];
xy10q[[All, 3]] = Log10[xy10q[[All, 3]]];
ListPlot3D[xy10q, InterpolationOrder -> 1, ViewPoint -> {Infinity, 0, 0}]


From the above plot it is clear that the dataset isn't suited for producing a contour plot because it contains a lot of noise. Here is a slice from the middle:

ListPlot[Cases[xy10q, p : {0.254, _, _} :> Rest@p]]
`

So you should define your goal more precisely: what information you actually wish to extract from your very noisy dataset containing a lot of zeros in the $z$-coordinate? Also it might help if you explain what this data mean.

• Thanks Alexey, Your response is helpful. I also modified the post accordingly. Aug 20, 2016 at 8:02