
|
Solution Number: 7581
Date Last Modified: Feb 18 1997 9:38AM |
|
| Title: How can I plot a 3D scatterplot of spheres? | |
| Product: MATLAB | Platform: All Platforms |
Problem:
How can I plot a 3D scatterplot of spheres? |
|
Solution:
In order to plot small spheres in a 3D scatterplot, you will need to use the SPHERE function to generate the appropriate data and use your X,Y,Z data as the center for each sphere. For instance: t = 0:.3:2*pi; x = cos(t); y = sin(t); z = y.^2; c = 1:length(x); % C is a number corresponding to a row in the colormap hold for i = 1:length(x) [x1,y1,z1]=sphere(10); x1 = x1/5; y1 = y1/5; z1 = z1/5; surf(x1+x(i),y1+y(i),z1+z(i),c(i)*ones(size(z1))) end view(3) shading interp To make smaller globes, adjust the value that you divide into x1,y1, & z1. |
|
|
| |