Plotting 4 column of data

Hi everybody
I have obtained 4 column of data from an experiment. They are X, Y, Z as positions and d as density.
This density is the electron density around an atom.
I want to plot this data in such a way that d represents the color and wherever d is low, there is light color and wherever d is high, there is a dark color.
I imported the data to matlab and selected surf function but the 3d curve is very inaccurate and ugly :D
How can I plot such a curve? I am a beginner in matlab by the way.
Thanks :)

1 个评论

Are the X, Y, Z regularly spaced, or are they irregular? Is there only one Z per (X,Y) combination ?

请先登录,再进行评论。

回答(3 个)

Ilham Hardy
Ilham Hardy 2013-3-25

0 个投票

Hi reza,
How do you define the very inaccurate and ugly graph? can you post the resulted graph? By the way dou you need curve or 3d-shaded surface? If you need the latter, surf is the correct choice.
See more documentation of the surf, by typing doc surf in you rcommand window..
See also..
reza
reza 2013-3-25

0 个投票

I need clouds. The density of electrons are like clouds around atoms. My data should result in several clouds in the XYZ cordination. d is in fact the color of these clouds.
This is what I got and is not what I want.
X, Y and Z are irregularly spaced.
Thanks
Try scatter3. Assuming data is your n x 4 matrix:
scatter3(data(:,1), data(:,2), data(:,3), [], data(:,4), 'filled');

17 个评论

How should I do that? I am importing my data from a file to matlab. How I should I address this command to that file?
You indicated that you had already imported the data. Replace the variable name "data" in Kelly's example with the name of the variable you stored your imported data in.
How are you importing it? Load? Importdata? Uiimport? Textscan? Any of these (and many other methods) will eventually add the add variables to your workspace, and then you can call the scatter3 function with the appropriate variables.
I pressed file tab in the main menu and pressed import data from that tab.
Now in the work space, in the variable editor, I have 4 columns. Their names are 1 2 3 4 at the top and 260000 data under each of them.
How should I proceed?
Thanks a lot guys
reza
reza 2013-3-25
编辑:reza 2013-3-25
This is what I got folks ... It is a lot better but is it possible to make it better? It is a bit strange ! It is not 3d like clouds I want
Still not clear on what you're doing. My best guess... you're opening the uiimport dialogue via the "Import Data" icon in Current Folder window. And then... what? Do you choose to import the entire file as one variable? How did you generate the plots above? Are you just clicking on plots in the Current Folder dropdown box, or are you actually coding it?
For the scatter3 solution (which will give the 3D clouds you're looking for), you're going to need to import the data into a variable, since I don't think it's an option in the dropdown box (I could be wrong, because I never use those Desktop tools, but I didn't see it there on a quick scan). If you describe the format of your file, I can give an example.
The format of the file is unknown to me. It was generated from a code for simulating of the electron clouds around silicon atoms.
But I think it is a simple text file with 4 columns of numbers.
As I told before, I simply used the import data option in the main menu in matlab.
This image shows how I import.
This is what I should get but I still cannot. This picture is given to me by my supervisor.
The yellow spots are silicon atoms and I should get the blue ones which are those clouds.
The variable editor would have a variable name as well as the data. Just above the "1" "2" "3" "4" header for the columns, there would have been a line saying something like
uidata <260000 x 4 double>
The word ("uidata" in my example here) to the left of the size information is the variable name. It might be a name very similar to your file name.
Oh yes, I figured it out.
Thanks, I plot it as you can see some posts above.
What is your current scatter3() result?
What colormap() do you have in effect? If it starts out dark and goes light for higher values, reverse it. For example
colormap( flipud(copper(64)) )
You can see the result of scatter3 in several posts higher.
My supervisor said, the result is a 3D image but it should be shown in 2D. How can I convert the scatter3 3D image to a 2D one?
Are you referring to your image in "This is what I got folks" ? Could you upload your file? http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Yes I mean that file.
Oh I am sorry. The data are confidential. I know your good will but I am not allowed to share this result anywhere.
Have you seen my last image? I need to reach this instead of what I got. What I have is 3D but what I want to 2D projection.
I am a bit cautious. scatter3() is not going to give you that kind of solid blue background on the axes -- not unless the data that happens to fall there is very dense. If you zoom in, does it remain solid blue or does it show individual dots ? What if you use a smaller dot size?
clf
dotsize = 6; %for example
scatter3(data(:,1), data(:,2), data(:,3), dotsize, data(:,4))
What shows up for min() and max() of your data columns, by the way? Which colormap are you using? Did you try reversing the colormap ?
I reversed the colormap and it turns to orange instead of blue. That's it. Nothing more happened.
Right now the min and max of the axes are 0-20 0-40 and 0-60.
I have 268000 points with (XYZd)
When I zoom in, it is not solid line but it consists of very small dots which are very close to each other.
What is min() and max() of the d data?
Try using the rotate to move the image around. The solid-looking background: does it turn out to be organized into planes, more or less? If you pan to move the edges into or out of view, does a "wall" disappear?

请先登录,再进行评论。

类别

标签

提问:

2013-3-25

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by