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 个评论
Walter Roberson
2013-3-25
Are the X, Y, Z regularly spaced, or are they irregular? Is there only one Z per (X,Y) combination ?
回答(3 个)
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..
Kelly Kearney
2013-3-25
Try scatter3. Assuming data is your n x 4 matrix:
scatter3(data(:,1), data(:,2), data(:,3), [], data(:,4), 'filled');
17 个评论
reza
2013-3-25
Walter Roberson
2013-3-25
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.
Kelly Kearney
2013-3-25
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.
reza
2013-3-25
Kelly Kearney
2013-3-25
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.
reza
2013-3-25
Walter Roberson
2013-3-25
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.
reza
2013-3-25
Walter Roberson
2013-3-25
What is your current scatter3() result?
Walter Roberson
2013-3-25
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)) )
reza
2013-3-25
Walter Roberson
2013-3-25
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
reza
2013-3-25
Walter Roberson
2013-3-25
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 ?
reza
2013-3-25
Walter Roberson
2013-3-26
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?
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

