Scatter in MATLAB®

How to make a scatter plot in MATLAB®. Seven examples of the scatter function.


load seamount x y z;

fig = figure;
scatter(x, y, 10, z);

title('Undersea Elevation');
xlabel('Longitude');
ylabel('Latitude');

fig2plotly();
x = [1 2 3 4 5]
y = [3 4 6 3 6]
% Create a scatter plot using the scatter function

fig = figure;
scatter(x, y);

% Add title and axis labels
title('Simple Plot from array');
xlabel('X');
ylabel('Y');

fig2plotly(fig);
fig = figure;
load seamount;
s = 10;
c = linspace(1,10,length(x));
scatter(x,y,s,c)
zoom(2)

fig2plotly(fig, 'strip', false);
a=[1:10;sin(1:10);cos(1:10)]';

fig = figure
scatter(a(:,1), a(:,2));
title('Sample Data');

fig2plotly(fig);
x = -2:0.25:2;
z1 = x.^exp(-x.^2);
z2 = 2*x.^exp(-x.^2);
real_z1 = real(z1);
imag_z1 = imag(z1);

real_z2 = real(z2);
imag_z2 = imag(z2);

plot(real_z1,imag_z1,'g*',real_z2,imag_z2,'bo');
title('Plotting Complex Data');

fig2plotly();
X = [linspace(0,100,100); linspace(0,100,100); linspace(0,100,100)]
Y = [randi(100,1,100); randi(100,1,100); randi(100,1,100)]

colors = ['r' 'g' 'b']
fig = figure;
hold on
for i=1:3
  disp(colors(i));
  scatter(X(i, :), Y(i, :),colors(i));
end;
hold off

fig2plotly(fig, 'strip',false)
X = [1 2 3 4 5]
Y = [5 5 5 5 5]

fig = figure;
colors = ['r' 'g' 'b' 'y' 'c']

hold on;
for i=1:5
    scatter(X(i), Y(i), 'LineWidth',10,'MarkerFaceColor',colors(i))
end
hold off;
resp = fig2plotly(fig)