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 !

  • 3
    $\begingroup$ 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 $\endgroup$ May 6, 2012 at 10:41
  • 9
    $\begingroup$ 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) $\endgroup$
    – Szabolcs
    May 6, 2012 at 10:56
  • 4
    $\begingroup$ Did you try Import? $\endgroup$ May 6, 2012 at 13:56

2 Answers 2

(*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:
(* Finally import it and plot*)


enter image description here


I had no problems at all downloading your sample file and plotting it:

enter image description here


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

enter image description here

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.


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.