Plot 2d image from 3D data Mathematica


by abikutn
Tags: mathematica 8, plot3d, raster scan
abikutn
abikutn is offline
#1
May6-12, 01:23 PM
P: 10
hello guys,

I have a CSV file with hyuge set of data devided into 3 cols. Y position X position and corresponding intensity values.

I want to plot the image , my thesis is laser- microscopy. so a 2D plot ( density plot ) based on these values.

The following is what I have tried so far!
plotdata = Import["test2 10 10.csv", "Table"]
ListPlot3D[plotdata]
But above results in : is not a rectangular array larger than 2 x 2. >>

Can anyone help me how to deal with such a huge set of data and how to plot it as 2D image ( Grey scale is also fine )

Thank you,

abhi - abikutn@gmail.com
Attached Files
File Type: zip test2 10 10.zip (866 Bytes, 8 views)
Phys.Org News Partner Science news on Phys.org
Better thermal-imaging lens from waste sulfur
Hackathon team's GoogolPlex gives Siri extra powers
Bright points in Sun's atmosphere mark patterns deep in its interior
Bill Simpson
Bill Simpson is offline
#2
May6-12, 02:17 PM
P: 972
If your complete dataset is a square matrix of {x,y,z} in the same form as your small sample then this may work for you

xyz = Import["test2 10 10.csv"];
z = Partition[Map[Last, xyz], 10];
ArrayPlot[z, ColorFunctionScaling -> True]

That depends on your data being a square matrix and you need to set the size of the partition to restore your data to be a square matrix of z values.

This has been done of samples with a million data points and might work with larger values if needed.
abikutn
abikutn is offline
#3
May6-12, 02:24 PM
P: 10
Thanks for your reply and support

"That depends on your data being a square matrix and you need to set the size of the partition to restore your data to be a square matrix of z values. "

by saying this: suppose I have 10 by 10 pixels with some intensity values Z for each pixel.

So partition meaning I have to split it 10 by 10 so that its a square matrix ?

and what is the meaning of machine size values ?

Thank you

abikutn
abikutn is offline
#4
May6-12, 02:30 PM
P: 10

Plot 2d image from 3D data Mathematica


I suggest you take a look at the CSV file I have attached.

for example I have y{1->10} and x{1->10}
The way the values are recording in the CSV is as:

[step1: y=1, get values for X{1->10}
step2: increment y and repeat process till Y=max]

Will this affect in anyway how the plot forms based on its actual X and Y co ordinates ???
Just a question. I am not sure if you got my understanding.Basically wont the code you gave mix up all Z values with respect to their X and Y ?
djelovin
djelovin is offline
#5
May6-12, 06:23 PM
P: 26
Remove that "Table" from import, use something like this:
plotdata = Import["test2 10 10.csv"]
z = GatherBy[plotdata, First][[All, All, 3]]
ArrayPlot[z, ColorFunction -> "Rainbow"]
Bill Simpson
Bill Simpson is offline
#6
May6-12, 07:08 PM
P: 972
Quote Quote by abikutn View Post
I suggest you take a look at the CSV file I have attached.
;...
Just a question. I am not sure if you got my understanding.Basically wont the code you gave mix up all Z values with respect to their X and Y ?
I did use your CSV file to write and test the example I gave you.
Thank you for the example data. That makes it much easier to provide correct answers.
I believe that it does correctly keep the position of the Z values.

You should ALWAYS carefully test any code to make sure that it is correct.
Compare your matrix before any changes and after my calculation to verify this.

I had intended to use an even simpler method of obtaining the Z values but for some reason I just didn't think of a simpler method when I posted my first reply.
abikutn
abikutn is offline
#7
May7-12, 11:48 AM
P: 10
Thank you! ... That was a good start ...

in the list density plot how can I change the color variation to grey scale image ? Is there a colorscaling function for grey scale just like how it can be done for RGB with ranibow ?

Abhi
djelovin
djelovin is offline
#8
May7-12, 12:10 PM
P: 26
Just remove ColorFunction -> "Rainbow",
e.g.

ArrayPlot[z]


Register to reply

Related Discussions
Plot 3D matrix as 2D plot and 3rd dimension as color in Mathematica Math & Science Software 8
Rasterized density plot + countour plot in Mathematica (to solve EPS issues) Math & Science Software 0
Import and plot multiple data sets in Mathematica Math & Science Software 14
Mathematica: Plot time evolution data in 3D Math & Science Software 6
Mathematica plot envelope data smoothing Math & Science Software 1