scatter3Create a 3-D scatter plot. Use
sphereto define vectorsx,y, andz.
figure [X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)]; scatter3(x,y,z) fig2plotly()
Use
sphereto define vectorsx,y, andz.
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)];
Define vector
sto specify the marker sizes.
S = repmat([100,50,5],numel(X),1); s = S(:);
Create a 3-D scatter plot and use
viewto change the angle of the axes in the figure.
figure scatter3(x,y,z,s) view(40,35) fig2plotly()
Corresponding entries in
x,y,z, andsdetermine the location and size of each marker.
Use
sphereto define vectorsx,y, andz.
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)];
Define vectors
sandcto specify the size and color of each marker.
S = repmat([50,25,10],numel(X),1); C = repmat([1,2,3],numel(X),1); s = S(:); c = C(:);
Create a 3-D scatter plot and use
viewto change the angle of the axes in the figure.
figure scatter3(x,y,z,s,c) view(40,35) fig2plotly()
Corresponding entries in
x,y,z, andcdetermine the location and color of each marker.
Create vectors
xandyas cosine and sine values with random noise.
z = linspace(0,4*pi,250); x = 2*cos(z) + rand(1,250); y = 2*sin(z) + rand(1,250);
Create a 3-D scatter plot and fill in the markers. Use
viewto change the angle of the axes in the figure.
scatter3(x,y,z,'filled') view(-30,10) fig2plotly()
Initialize the random-number generator to make the output of
randrepeatable. Define vectorsxandyas cosine and sine values with random noise.
rng default z = linspace(0,4*pi,250); x = 2*cos(z) + rand(1,250); y = 2*sin(z) + rand(1,250);
Create a 3-D scatter plot and set the marker type. Use
viewto change the angle of the axes in the figure.
figure scatter3(x,y,z,'*') view(-30,10) fig2plotly()
Initialize the random-number generator to make the output of
randrepeatable. Define vectorsxandyas cosine and sine values with random noise.
rng default z = linspace(0,4*pi,250); x = 2*cos(z) + rand(1,250); y = 2*sin(z) + rand(1,250);
Create a 3-D scatter plot and set the marker edge color and the marker face color. Use
viewto change the angle of the axes in the figure.
figure
scatter3(x,y,z,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[0 .75 .75])
view(-30,10)
fig2plotly()
Starting in R2019b, you can display a tiling of plots using the
tiledlayoutandnexttilefunctions.Load the
seamountdata set to get vectorsx,y, andz. Call thetiledlayoutfunction to create a 2-by-1 tiled chart layout. Call thenexttilefunction to create the axes objectsax1andax2. Then create separate scatter plots in the axes by specifying the axes object as the first argument toscatter3.
load seamount tiledlayout(2,1) ax1 = nexttile; ax2 = nexttile; scatter3(ax1,x,y,z,'MarkerFaceColor',[0 .75 .75]) scatter3(ax2,x,y,z,'*') fig2plotly()
Use the
spherefunction to create vectorsx,y, andz.
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)];
Create vectors
sandcto specify the size and color for each marker.
S = repmat([70,50,20],numel(X),1); C = repmat([1,2,3],numel(X),1); s = S(:); c = C(:);
Create a 3-D scatter plot and return the scatter series object.
h = scatter3(x,y,z,s,c); fig2plotly()
Use an RGB triplet color value to set the marker face color. Use dot notation to set properties.
h.MarkerFaceColor = [0 0.5 0.5]; fig2plotly()