# How can I plot Intensity values(Z) based on X and Y position. Data stored as 3 columns in CSV file

I have a CSV data file with X position, Y position and corresponding intensity as Z.

I would like to plot it to form an image. I have an idea that list density plot is one method,but, somehow the importing of the CSV file as table and plotting is resulting in an error :

Read::readn: "Invalid real number found when reading from "test2 10 10.csv."


I am totally new to Mathematica and just learning. I don't understand why it takes so long to even import a CSV file.

Thanks !

• It may help to get a good answer if you post your code and some example data. I'm sure you'll have a solution in no time at all then May 6, 2012 at 10:41
• Please try to isolate the specific issue that's causing problems, and post a minimal working examples (i.e. the smallest code snippet and input file that reproduces the problem). It seems that you are having trouble importing from CSV---this is a separate problem from plotting. We can't find out what goes wrong with the CSV import without seeing a sample data file (please try to create the smallest possible CSV that reproduces the problem, preferably just a few lines, and post it together with the code you used for importing) May 6, 2012 at 10:56
• Did you try Import? May 6, 2012 at 13:56

(*Testing ...
First we generate some points*)
points = Flatten[Table[{x, y, PDF[BinormalDistribution[{0, 0}, {1, 2}, .5], {x, y}]},
{x, -3, 3, .1}, {y, -3, 3, .1}], 1];
(*
Now we export it as a csv
*)
Export["c:\\points.csv", points];

(* The file looks like this:
-3.,-3.,0.0010207851317789406
-3.,-2.9,0.0010190852401957891
-3.,-2.8,0.0010140025313558822
-3.,-2.7,0.0010055876210847213
-3.,-2.6,0.0009939239359647277
...
*)
(* Finally import it and plot*)

ListDensityPlot[Import["c:\\points.csv"]] Edit Looking at the sample file, it seems that your data may be on a regular grid:

data = Import["wafer test 5-8-12 test5.csv"];

data = GatherBy[data, First];

Equal @@ dd[[All, All, 2]]

(*
==> True
*)


which means that we could also use ArrayPlot, if you want a more 'discrete' appearance:

ArrayPlot[Transpose[dd[[All, All, 3]]], ColorFunction -> "SolarColors"] I had to transpose my data since I gathered by the x values, so each row of data ends up being constant x instead of y. Also you might want to use the DataReversed option for ArrayPlot, since ArrayPlot and ListDensityPlot treat arrays slightly differently.